I have a folder with folders inside of them, named 1.1, 1.2, 1.3 ... 1.30.
I want to delete all folders except the last 10 versions
So delete all folders except 1.20, 1.21, 1.22, 1.23, 1.24, 1.25, 12.26, 1.27, 1.28, 1.29, 1.30
I also want to make sure that if there are 10 or fewer then none get deleted
Somthing like works but it wont preserve the last 10 versions
ls | sort -v | head -n +10 | xargs -I {} rm -- {}
How can I do this?