[ALUG] Scripting help: deleting old directories

James Bensley jwbensley at gmail.com
Fri Dec 24 18:31:17 GMT 2010

Off the top of my head I can't remember and I'm at a winpoo computer
right now, but this can be down with find;

find /a/dir* -mtime +7 -exec rm {} \;

This will delete all files in a directory that are 7 days old,
obviously 'man find' and 'man rm' are going to help. Since you want to
delete the containing folder also perhaps nest this in a loop, with an
outter loop deleting the folder if its empty because the inner loop
cleared it out because the files inside met your age
criteria...Dangerous, but I like it! :D



There are 10 kinds of people in the world; Those who understand
Vigesimal, and J others...?

More information about the main mailing list