How to delete files older than N Days
You can delete files older than N days using the find utility in Linux. The command syntax is shown below:
find <Directory_Path> -mtime <Number_Of_Days> -exec rm {} \;
Example:
find /home/grepitout/Downloads -mtime +7 -exec rm {} \;
The above command searches and delete seven days old files in the directory “/home/grepitout/Downloads“.
That’s it!
If you like this post and wish to receive more articles from us, please like our FB page: Grepitout
Your suggestions and feedbacks will encourage us and help to improve further, please feel free to write your comments.
For more details on our services, please drop us an E-mail at info@grepitout.com
Great post! Here is another option. Specify the date from which we want to delete the files:
find /SYSADMIT/* -type f -not -newermt “AAAA:MM:DD HH:MI:SS” -delete
Extracted from: https://www.sysadmit.com/2019/08/linux-borrar-ficheros-por-fecha.html