Remove files created more than 30 days ago

I wanted to find all the files in a certain directory that were created more than 30 days ago. I started with:

find /path/to/dir -ctime +30

This was finding directories also, so I added -type

find /path/to/dir -ctime +30 -type f

This listed all the files I wanted, so I just passed -exec

find /path/to/dir -ctime +30 -type f -exec rm {} +

The {} in the -exec is replaced with the file names found, so all the files are removed.



Note: Replies will be formatted with PHP Markdown Extra syntax.

Name: Email (Not Required):
 
Logged IP: 3.139.107.241
To prevent spam please submit by clicking the kitten: