Write command to delete all the files from a directory which have been created after a specified time.

Showing Answers 1 - 6 of 6 Answers

samiran

  • Jun 13th, 2007
 

Say you want to delete some files ends with data which are 2 days old.


for file in `find . -follow -type f  -name "*data"  -mtime +2`
do
rm $file
done

  Was this answer useful?  Yes

samsbery

  • Jun 27th, 2008
 

find -type f -name "*info" -mtime +1 | xargs rm

This will delete all the files which ends with "info" and created 1 day ago. Please correct me if this is not correct!

  Was this answer useful?  Yes

cmanne

  • Sep 2nd, 2009
 

find -name "*.dmp" -mtime +180 -exec rm -f {} ;

The above one liner will delete the files after searching for the coredump files under the specified directory path which are older than 180 days.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions