Find and remove Files in Unix older than the specified number of days

For finding the files older than 31 days

find . -name “filename.ext” -mtime +no_of_days -exec ls -ltr {} \; e.g   find . -name “*req” -mtime +31 -exec ls -ltr {} \;

Verify the timestamp of all the files.They must be older than 5 weeks For Deleting files older that 31 days :

find . -name “*req” -mtime +31 -exec rm {} \;

Verify after execution of the above.

Execute:  find . -name “*req” -mtime +31 -exec ls -ltr {} \;

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*


8 − = one

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>