Using find with mtime
March 2, 2008 Commands, Scripting No CommentsThe ‘find’ command is a very powerful search tool in UNIX systems. The mtime option comes in very handy when I am trying to troubleshoot a problem, automate tasks or do forensics. Below are some examples:
Finding all files owned by apache modified in the last 3 days within /var/www/html:
find /var/www/html -type f -user apache -mtime -3
Finding all files that were modified 3 days ago or before in the current directory:
find . -type f -mtime +3
Deleting all files in the current directory older than (modified before) 100 days:
find . -type f -mtime +100 -exec rm -f '{}' \;

