Delete files older than X nuber of days

Here is another bash one-liner. This one will help you find and delete files older than X number of days. Very useful in a directory full of various types of logs, such as /var/log:

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

This assumes, that you are already in the directory in question. Simply replace X with the number of days you need. For example:

find .  -type f -mtime +3 -exec rm -rf {} \; ;done

will delete all files older than 3 days.

Bookmark and Share

  • No Related Post
bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark
tabs-top  banner ad


Leave a Reply