[PLUG] disk space by user
Randal L. Schwartz
merlyn at stonehenge.com
Wed Oct 30 18:34:45 UTC 2002
>>>>> "david" == david may <david at davudsplace.net> writes:
david> i'd prolly use something like this but i'll bet you get some perl
david> to do the same thing as well.
david> find . -mount -printf "%u %k\n" | awk '{total[$1]+=$2;};END {for (i in total ) {print total[i], i;};}'
use File::Find;
my %total_blocks;
find sub {
my @stat = lstat or return;
$total_blocks{$stat[4]} += $stat[12];
}, "/";
for (sort keys %total_blocks) {
printf "%3d %10s %d\n",
$_, scalar getpwuid($_), $total_blocks{$_};
}
If you want it sorted by biggest disk wasters, er, users, replace
that last loop start with:
for (sort { $total_blocks{$b} <=> $total_blocks{$a} } keys %total_blocks) {
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
More information about the PLUG
mailing list