Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete directory and files 5 days old

Status
Not open for further replies.

Midrange

Vendor
Aug 28, 2002
135
SG
Hi there i'm new with unix environment, just wantto know how can i delete the directory which is 5 days old..

I have a directory

/backup/system/Dir1
/backup/system/Dir2......./Dir15

I want to delete the directory under the /backup/system which is 5 days old. I've tried my own step but only delete the files under but didn't delete the directory itself and its subdirectories..

tnx
 
to delete the +5 days old directories and their contents :
find . -type d -mtime +5 -exec rm -r {} \;
Check out the man pages and other threads in this forum.
HTH
;-) Dickie Bird
Honi soit qui mal y pense
 
Dickie's right, but be careful about using . with find and rm - executing it from the wrong place can be disasterous. Better in my view to explicitly dive find the top-level directory to work in, ie:

find /name_of_directory -type d -mtime +5 -exec rm -r {} \;


HTH.
 
I have tried to read the man page for the meaning of -mtime . It says ,

-mtime Number : Evaluates to the value True if the file has been modified in Number-1 to Number multiples of 24 hours

To be honest , I am confused by this explaination , can anybody please elaborate the same ??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top