Find And Delete Files Older Than X Days

by Kyle on · Posted in

Delete files older than X days:

find . -type f -mtime +X -exec rm {} \;

If you want to search a specific directory:

find /path/to/files -type f -mtime +X -exec rm {} \;

You can also delete directories by switching the flag type:

find . -type d -mtime +X -exec rm {} \;

Save. Share. Submit.

Related Snips

Hide Sidebar