in reply to File::find and skipping directories
find(\&offenders, $dir); sub offenders{ # recurse directories $File::Find::prune = 0; # there are some shared directories # that we do not want to include my @dirs = '\/home\/engineering\/dev\/share'; foreach my $z (@dirs){ #print "$z eq $File::Find::dir\n"; return if ($File::Find::dir =~ m/$z/) } # do not include links return if (-l); # owner of file but skip # if owner is not a user # (uid < 500) # #return if ($uid < 500); $uid = (lstat($_))[4]; if (-d && $uid < 500){ # check do not recurse these # dirctories $File::Find::prune = 1; print "UID is $uid, skipping $File::Find::dir, $File::Find::na +me, $_\n"; return; } # scan only regular files if (-f){ $uname = getpwuid $uid; # gather name of file $fname = $File::Find::name; # size of file (kb) $size = (lstat($_))[7]; $size = int($size/1000); # keep running total of each # user's space use $size{$uname} += $size; } }
This skips everything. Here is the output:
Then the program exits.UID is 0, skipping /home, /home, .
Neil Watson
watson-wilson.ca
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: File::find and skipping directories
by sacked (Hermit) on Jun 03, 2004 at 15:49 UTC |