posted 15 years ago
If you can rely on the file's own filesystem date, the output of "ls -l[r]t" can be used. Something like:
ls -lrt | tail -l -3 | xargs rm
WARNING: Major corrections probably required.
I prefer my naming conventions to be more in the line of "fileYYYYMMDD.tar.gz" myself. Not only can you use a simple sort, it avoids confusion about American/English date formats (MM/DD/YY vs. DD/MM/YY) - not to mention other countries. Named months are not well-suited for date arithmetic, even when international issues don't figure in.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer