Skip to content

Find and Remove Old Files on Linux

bash-3.00# find FOO/*bar* -mtime +30 -exec ls -lh {} \;
-rwxrwxrwx   1 143      staff        16G Jul 13 04:08 FOO/bar_backup_201207130403.bak
...snip
-rwxrwxrwx   1 143      staff        16G Sep 12 18:34 FOO/bar_backup_201209121827.bak

bash-3.00# find FOO/*bar* -mtime +30 -exec rm -f {} \;

bash-3.00# find FOO/*bar* -mtime +30 -exec ls -lh {} \;
Published inBashLinux