From 3163f7d94d498b022b28744bf8f5edd69cc1c069 Mon Sep 17 00:00:00 2001 From: hjp Date: Sat, 24 Apr 2010 15:25:15 +0000 Subject: [PATCH] create histogram of file sizes --- filesize/filesize | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 filesize/filesize diff --git a/filesize/filesize b/filesize/filesize new file mode 100755 index 0000000..114882c --- /dev/null +++ b/filesize/filesize @@ -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; +} +