Sunday, March 20, 2011

Finding and Deleting Files in Unix older than the specified number of days



syntax : 

For finding the files older than 35 days

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

 Verify the timestamp of all the files.They must be older than 5 weeks

For Deleting files older that 35 days :

find . -name "*req" -mtime +35 -exec rm {} \;

Verify after execution of the above.

Execute:  find . -name "*req" -mtime +35 -exec ls -ltr {} \;


No comments:

Post a Comment