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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Delete all files in sub-dir +10 old

Reply to Message Icon

Name: ihosail
Date: October 3, 2005 at 06:59:29 Pacific
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



Sponsored Link
Ads by Google

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

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


0

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

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


rape movies
Mr.Gordon BE


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Delete all files in sub-dir +10 old

need help with auto file delete www.computing.net/answers/unix/need-help-with-auto-file-delete/7546.html

Comparing all files in current dir www.computing.net/answers/unix/comparing-all-files-in-current-dir/4102.html

delete files in specific directory www.computing.net/answers/unix/delete-files-in-specific-directory/7357.html