I have a directory with database backups stored in data-atm1-YYYYMMDDHHMMSS.sql.gz
filename format.
Q: How do I delete all files but I need to keep last X files? (ordered in descendant order by filename).
I have a directory with database backups stored in data-atm1-YYYYMMDDHHMMSS.sql.gz
filename format.
Q: How do I delete all files but I need to keep last X files? (ordered in descendant order by filename).
*(On[11,-1])
(although probably mtime would also work here - unless the names of the backups do not correspond to their true dates) – steeldriver Mar 17 '21 at 14:32