Find and delete files that was modified more than 30 minutes ago

find /var/tmp -type f -mmin +30 -exec rm {} \;

Find and delete files that was create more than 30 minutes ago

find /var/tmp -type f -cmin +30 -exec rm {} \;

Other options:

  • -ctime +2 # created 48 hours ago

  • -mtime +3 # modifed 72 hours ago

  • -amin +30 # accessed minutes

  • -atime +10 # accessed 10 days ago

To add .gitignore files to all empty directories recursively from your current directory

find . \( -type d -empty \) -and \( -not -regex ./\.git.* \) -exec touch {}/.gitignore \;

Delete files that was modified 60 minutes ago

find /tmp -maxdepth 1 -type f -mmin +60 -delete