11/25/2015

[Linux] find old files and delete, or move



Example: delete files older than one year
find /path/to/source  -mtime +365 -exec rm {} \;

Example: move files older than one year.
find /path/to/source -mtime +365 -exec mv {} /path/to/destination/ \;

Example: find files which file name starts ABC and older than 30 days and move.

find . -name "ABC*.csv" -mtime +30 -exec mv {} /path/to/destination/  \;