Computing.Net > Forums > Unix > Delete all files in sub-dir +10 old

Delete all files in sub-dir +10 old

Reply to Message Icon

Original Message
Name: ihosail
Date: October 3, 2005 at 06:59:29 Pacific
Subject: Delete all files in sub-dir +10 old
OS: Unix
CPU/Ram: Unix
Comment:

Please help...

I need to delete files in all sub-directories that are more than 10 days old or delete all sub-directoires (entire directory) that's 10 days old (this is risky).
I have an archive directory /archive and many subdirectories as /archive/Sep01, /archive/Sep02 etc. with month and day naming convention.


This command will delete all files that were modified 10 days ago:
find /archive -type f -mtime +10 -exec rm {} \;

How do I use similar command to delete all files within the sub-directories of /archive as well?

Any help would be greatly appreciated. Thank you!

ihosail


Report Offensive Message For Removal


Response Number 1
Name: anupam
Date: October 3, 2005 at 20:44:52 Pacific
Reply: (edit)

find command is recursive....it will delete all files in your sub directories of /archive as well according to the condition that you have given to it.

Anupam


Report Offensive Follow Up For Removal

Response Number 2
Name: GordonBe
Date: November 30, 2005 at 12:17:13 Pacific
Reply: (edit)

Also for dirs you need to set -rf flag for rm to force deletion.


rape movies
Mr.Gordon BE


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Delete all files in sub-dir +10 old

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge