Need a script to move files where their last mod date <= 'xx
MMM yyyy'
Geoffrey D. Bennett
g at netcraft.com.au
Fri Nov 17 06:11:20 CST 2006
On Fri, Nov 17, 2006 at 02:18:37PM +1030, Evan wrote:
[...]
> List further to this query I came up with the following block of code
> pieced together from googling etc
> It unfortunately doesn't work based on the output im seeing. Can anyone
> help.
[...]
> $dir="/var/log/copfilter/default/opt/proxsmtp/quarantine";
> opendir(BIN, $dir) or die "Can't open $dir: $!";
> my $cnt = 0;
> foreach my $file (grep {/\./} sort by_last_mod readdir BIN){
[...]
> sub by_last_mod {
> # vars $a and $b automatically passed in
> # perl function 'stat' returns array of info on a file
> # 10th element of the stat array is last modified date,
> # returned as number of seconds since 1/1/1970.
> my $adate = (stat(a))[10]; # get last modified date
Shouldn't that be stat("$dir/$a") ?
--
Geoffrey D. Bennett, RHCE, RHCX mailto:g at netcraft.com.au
Senior Systems Engineer sip:g at netcraft.com.au
NetCraft Australia Pty Ltd http://www.netcraft.com.au/geoffrey/
More information about the linuxsa
mailing list