no space left?

Ben Steeves ben.steeves at gmail.com
Tue Oct 26 12:13:27 UTC 2004


On Tue, 26 Oct 2004 11:56:26 +0800 (HKT), HaJo Schatz <hajo at hajo.net> wrote:
> Had this issue once and found it too tedious to try and run through my
> whole fs with du. Since then, I keep a graphical util handy. Try eg
> filelight (http://methylblue.com/filelight/ ). That should instantaneously
> show you where your space went.

Share and enjoy (and no comments on the lazy programming -- I banged
this together quickly):

#!/usr/bin/perl

open DU,"du -sh * |" or die;
while (<DU>) {
   chomp;
   ($size, $file) = split /\s+/,$_,2;
   if ($size =~ /([0-9\.]+)([k|M|G])/) { $num = $1; $mod = $2; }
   else { $num = $size; $mod = 1; }
   if ($mod eq '1') { $num = $num * 1; }
   if ($mod eq 'k') { $num = $num * 1000; }
   if ($mod eq 'M') { $num = $num * 1000000; }
   if ($mod eq 'G') { $num = $num * 1000000000; }

   if (-d $file) { $dirs{"$num|$size|$file"} = 1; }
   else { $files{"$num|$size|$file"} = 1; }
}

close DU;

print "Files:\n";
foreach (sort {$a <=> $b} keys %files) {
   ($num, $size, $file) = split /\|/,$_,3;
   print "$size\t$file\n";
}
print "Dirs:\n";
foreach (sort {$a <=> $b} keys %dirs) {
   ($num, $size, $file) = split /\|/,$_,3;
   print "$size\t$file\n";
}

-- 
Ben Steeves                     _                    bcs at metacon.ca
 The ASCII ribbon campaign     ( )            ben.steeves at gmail.com
   against HTML e-mail          X                GPG ID: 0xB3EBF1D9
http://www.metacon.ca/bcs      / \     Yahoo Messenger: ben_steeves




More information about the fedora-list mailing list