Delete files older than 10 days using shell command

find is the common tool for this kind of task :

find ./my_dir -mtime +10 -type f -delete

EXPLANATIONS

./my_dir your directory (replace with your own)
-mtime +10 older than 10 days
-type f only files
-delete no surprise. Remove it to test your find filter before executing the whole command

Src: 
https://stackoverflow.com/questions/13489398/delete-files-older-than-10-days-using-shell-script-in-unix

Share

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.