linux find examples

  1. #find all files under /dir older than 7 days, and delete
  2. find /dir -type f -mtime +7 | xargs rm -f
  3. #find all files newer than FILE, and delete
  4. find /dir -type f -newer /path/to/FILE -exec rm \{\} \;
  5. #find all files older than 10 minutes, and print names(print is default)
  6. find /dir -type f -mmin +10 -print
  7. #find all files newer than 1 day, and tar them to file.tar
  8. find /dir -type f -mtime -1 | tar -c -T - -f file.tar