Hi,
I want to write a script that deletes all folders and keep the last 10 recent folders.
I know the following:
ls -ltr will sort the folders from old to recent.
ls -ltr | awk '{print $9}' will list the folder names (with a blank line at the beginning)
I want to get the 10th folder from the bottom. HOW?
Once I get it, I can run: find . ! -newer <this_object> -exec rm {} \;
Thanks,
PS: Any other suggestion is appreciated