create histogram of file sizes

This commit is contained in:
hjp 2010-04-24 15:25:15 +00:00
parent ef1903e49f
commit 3163f7d94d
1 changed files with 29 additions and 0 deletions

29
filesize/filesize Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/perl
use warnings;
use strict;
use File::Find;
my %seen;
my %hist;
sub collect {
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks) = lstat($_);
return if $seen{"$dev:$ino"};
$hist{$size}++;
}
find(\&collect, @ARGV ? @ARGV : ("."));
my $total_count;
for my $c (values %hist) {
$total_count += $c;
}
my $ac = 0;
for my $s (sort {$a <=> $b } keys %hist) {
$ac += $hist{$s};
printf "%g %g %6.2f\n", $s, $ac, 100 * $ac/$total_count;
}