in reply to Find files older than x days and delete them
Here is a script I have used for a similar task in one
directory. I have changed the name of the directory
for obvious reasons:
Amusing note. I wrote this after accidentally crashing someone else's ftp server by throwing the accumulated contents of a large dir at it. The next day I went and made every change I could think of that would have prevented the disaster. Running this script daily was one of those changes. :-)#! /usr/local/bin/perl die unless chdir "/some/hardcoded/dir/here"; die unless opendir DIR, "."; foreach $file (grep {-f && (14 < -M)} readdir DIR) { unlink $file; } closedir DIR;
EDIT
Hmmm...this was one of my earlier scripts. Definitely
before I learned the value of informative error messages.
And written in a hurry...but I think I should leave it
anyways as an example to show that my coding style has
matured...
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: RE (tilly) 1: Find files older than x days and delete them
by merlyn (Sage) on Aug 22, 2000 at 01:32 UTC | |
by atl (Pilgrim) on Aug 22, 2000 at 15:52 UTC | |
by merlyn (Sage) on Aug 22, 2000 at 16:01 UTC | |
by tilly (Archbishop) on Aug 22, 2000 at 16:20 UTC | |
by OzzyOsbourne (Chaplain) on Aug 22, 2000 at 23:09 UTC | |
by jcwren (Prior) on Aug 22, 2000 at 23:19 UTC |
In Section
Craft