Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Remove all but X most recent files in directory (See related posts)

Remove all but 5 (or whatever number) of the most recent files in a directory. Great if you have a directory of log files and you only want to keep a few of the recent ones.
rm `ls -t | awk 'NR>5'`


You need to create an account or log in to post comments to this site.


Related Posts