Jump to content



How to: Find and/or Delete files older than x days


  • Please log in to reply
No replies to this topic

#1 Wilson18



  • root
  • 112 posts
  • LocationUniversity of Birmingham

Posted 08 May 2015 - 06:21 PM

If you ever needed to locate files within a specific directory that are x days old (e.g. 7), you can use the following command within the terminal, just replace 7 with the number of days.

 find /directory -mtime +7

If you needed to say, delete these files, you can do the following

find /directory -mtime +7 -exec rm -f {} \;

This can be very useful. For examples, I use this to delete backups older then a few weeks old. 

List what you read?

Check me out on: YouTube, Twitter, Facebook, Google+

Also tagged with one or more of these keywords: Linux