![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| 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 11:09 AM |
| command for deleting log files based on some condition | pulkit | Shell Programming and Scripting | 4 | 01-09-2008 06:17 AM |
| Count of files based on date? | sbasetty | Shell Programming and Scripting | 6 | 01-11-2007 03:02 PM |
| deleting files on particular date | jazz | High Level Programming | 1 | 11-24-2005 11:45 AM |
| Deleting files older than a given date | rajugp1 | Shell Programming and Scripting | 3 | 12-09-2002 02:08 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | 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 01:07 PM.. Reason: missed out some words |
|
||||
|
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 |
![]() |
| Bookmarks |
| Tags |
| mtime |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|