четверг, 6 апреля 2023 г.

Linux Bash find multiple conditions and move files

remove only *.dat and *.csv files older than 4 moths 

find /path -type f -mtime +120 \( -name '*.dat' -or -name '*.csv' \) -exec rm '{}' ';'

or move the files, but please be aware if destination is wrong or some bad happens then you'll lose files 

find /path -type f -mtime +120 \( -name '*.dat' -or -name '*.csv' \) -exec mv '{}' /destination/ ';'