Skip to content

Commit

Permalink
Recurse into all paths passed to files.pl
Browse files Browse the repository at this point in the history
The script used to ignore all but the first CLI argument. Now,
we loop over ARGV and recurse into all paths. This makes it possible
to check the size of multiple folders in the root filesystem in one
go, excluding others that may live e.g. on another partition:

   files.pl /root /var /boot /etc /usr
  • Loading branch information
milianw committed Apr 6, 2017
1 parent 74764af commit 41d639f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions files.pl
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ sub usage {
print STDERR "Intended to be piped to flamegraph.pl. Full example:\n";
print STDERR " $0 /Users | flamegraph.pl " .
"--hash --countname=bytes > files.svg\n";
print STDERR " $0 /usr /home /root /etc | flamegraph.pl " .
"--hash --countname=bytes > files.svg\n";
exit 1;
}

usage() if @ARGV == 0 or $ARGV[0] eq "--help" or $ARGV[0] eq "-h";

my $dir = $ARGV[0];

find(\&wanted, $dir);
foreach my $dir (@ARGV) {
find(\&wanted, $dir);
}

sub wanted {
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size) = stat($_);
Expand Down

0 comments on commit 41d639f

Please sign in to comment.