Quickzi: Find files older than 5 days
Tuesday, November 23rd, 2010 at
4:52 pm
Here’s a quick command line tip to find files older than 5 days, and execute an action on those files:
find /home/foo/* -mtime +5 -exec echo {} > oldfiles.txt \;
&& mail -s "files older than 5 days" foo@foogazi.com < oldfiles.txt
This command searches for files that are older than 5 days, and sends the output to oldfiles.txt, then an email is sent to foo@foogazi.com with a list of the old files.
Alternatively, you could search for files older than 5 days, then delete them using this command:
find /home/foo/* -mtime +5 -exec rm {} \;
Popularity: 1% [?]
Like this post? Subscribe to my RSS feed and get loads more!













Leave a Reply