Tips for ‘FIND’ command

#find all files under /dir older than 7 days, and delete
find /dir -type f -mtime +7 | xargs rm -f

#find all files newer than FILE, and delete
find /dir -type f -newer /path/to/FILE -exec rm \{\} \;

#find all files older than 10 minutes, and print names(print is default)
find /dir -type f -mmin +10 -print

#find all files newer than 1 day, and tar them to file.tar
find /dir -type f -mtime -1 | tar -c -T – -f file.tar


About this entry