Advertisement
Advertisement
| 04.10.2008 at 11:10PM PDT, ID: 23314250 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: |
#!/usr/bin/perl
use File::Find ("find");
use strict;
my (%time, @dirs, $total, $atime, $mtime, $ctime, $aflag, $cflag, $mflag, $tflag);
$mtime=0;
$ctime=0;
$atime=0;
while (1) {
last unless $_=shift;
if (/^-a$/) {$aflag=1; $atime=shift; exit 1 unless $atime =~ /^\d*$/}
if (/^-m$/) {$mflag=1; $mtime=shift; exit 1 unless $mtime =~ /^\d*$/}
if (/^-c$/) {$cflag=1; $ctime=shift; exit 1 unless $ctime =~ /^\d*$/}
if (/^-t$/) {$tflag=1;}
push @dirs,$_ unless /^-/;
}
die {"Usage: $0 [-a <Days>,-m <Days>,-c <Days>] /Filesystem_pathname (Refer ReadMe file) \n"} unless $aflag || $cflag || $mflag;
die {"Usage: $0 [-a <Days>,-m <Days>,-c <Days>] /Filesystem_pathname (Refer ReadMe file) \n"} unless @dirs;
for (@dirs) {
print "\n ==> $_\n\n";
find(\&wanted, $_);
if ($tflag) {printf "\nTotal size of resultant files: %8.2f MB\n\n", $total / (1024 * 1024)};
$total = 0;
}
sub wanted {
if ($_ eq ".snapshot") {
$File::Find::prune=1;
}
elsif ((-f || -d ) && -A > $atime && -C > $ctime && -M > $mtime)
{
my $size = -s;
$total += $size;
print `ls -l $File::Find::name`, "\n";
#printf "%-75s\t%7d KB\n", $File::Find::name, ($size / 1024);
}
}
|