Quickzi: Find files older than 5 days

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 {} ;