The Linux find command

Written by James McDonald

June 20, 2008

I’m putting this here so I can recall it for later

find -mtime +2 -type f -print -exec mv {} /home/user/old/ \;

Basically it does the following: Find all files where the File’s data was last modified more than 2 days ago and run the move command on each file to move them to the specified directory.

find -mtime +2 -type f -print -exec rm -f {} \;

This one removes any files older than 2 days from the current directory. Don’t do this in /usr/bin!


Submit a Comment

Your email address will not be published.

You May Also Like…