I backup .mozilla every (re)boot to a folder ~/nas-backups/mozilla but I only want to keep the most recent 10 folders alphabetically. The backups are stored with a date stamp e.g. .mozilla_2018_11_05_08:13
I want to delete all but the most recent 10 as part of a script but as they are hidden files I can not find a way to do it:
rm -R 'ls -t | tail -n +11' as it ignores hidden files/folders.
I have tried rm -R 'ls -ta | tail -n +11' but that doesn't work either.
If it could be expanded so it only kept the first backup of each day that would be a bonus.
May I request an explanation of any suggestions? Thanks.
Any help please?