![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| deleting files based on file name and modified time | ammu | UNIX for Dummies Questions & Answers | 1 | 01-22-2008 07:09 AM |
| command for deleting log files based on some condition | pulkit | Shell Programming and Scripting | 4 | 01-09-2008 02:17 AM |
| Count of files based on date? | sbasetty | Shell Programming and Scripting | 6 | 01-11-2007 11:02 AM |
| deleting files on particular date | jazz | High Level Programming | 1 | 11-24-2005 07:45 AM |
| Deleting files older than a given date | rajugp1 | Shell Programming and Scripting | 3 | 12-09-2002 10:08 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Traversing thru dirs and deleting files based on date
Hi Folks
I am pretty new to unix and shellscripting. I need help on writing logic on traversing recursively through a set of directories under a top-level folder and delete files(mostly text) which are 1 month old. Can you people help me on this? Thanks a lot Ravi Last edited by ravi2082; 07-17-2007 at 09:07 AM. Reason: missed out some words |
| Forum Sponsor | ||
|
|
|
|||
|
This should do what you're looking for:
DAYS=30 echo 'Daily cleanup of backup directories more than' $DAYS 'days old' if [ -d /wasdata ] then FILES=`find /wasdata2 -type f -mtime +$DAYS` for f in $FILES do echo 'Deleting' $f rm $f done fi |