How can I delete all files that are older than one year in a specific folder with the bash under Linux?
Linux – Delete old files in a folder
bashlinux
bashlinux
How can I delete all files that are older than one year in a specific folder with the bash under Linux?
Best Answer
The only 2 commands used are find and rm.
Find looks for files (-type f), this to exclude directories, that are older then 3 days (-mtime +3). All it finds is given to rm (-exec rm {} \; ).
You could also place the rm statement outside of find, which is supposed to be faster:
find /u1/database/prod/arch -type f -mtime +3 | xargs rm