#!/usr/bin/perl -w use strict; use File::Find (); my $dir = shift; die "Not a directory: '$dir'\n" unless -d $dir; print "Blame for $dir\n"; my %blame = (); my $total = 0; my (%uid, %username, %name); while (my ($shortname, $pw, $uid, undef, undef, undef, $name) = getpwent) { next if exists $username{$uid}; $username{$uid} = $shortname; $name{$uid} = $name; } sub wanted { my (undef, undef, undef, undef, $uid, undef, undef, $size) = lstat($File::Find::name); $blame{$uid} += $size; $total += $size; } sub by_usage { $blame{$b} <=> $blame{$a} } File::Find::find({wanted => \&wanted}, $dir); print " Usage Login Comment\n"; foreach my $uid (sort by_usage keys %blame) { next if $blame{$uid} == 0; printf "%13s %12s %s\n", $blame{$uid}, $username{$uid}||$uid, $name{$uid}||$uid; } printf "%13s total disk used\n", $total;