#!/usr/bin/perl if (scalar @ARGV == 0 ) { open(FILE,"-|") || exec( "/usr/bin/du","-sk","."); } else { open(FILE,"-|") || exec( "/usr/bin/du","-sk",@ARGV); } while (<FILE>) { push @lista,$_; } close FILE; @lista= sort {$a<=>$b} @lista; for (@lista) { chomp; ($bytes,$nom)=split " ",$_,2; # ---- Version M 70.282.540 $tag=" "; $bytestot=$bytes; if ($bytestot >1000000000) { $bytestot= $bytestot/1000000000; $tag="T"; } elsif ($bytestot >1000000) { $bytestot= $bytestot/1000000; $tag="G"; } elsif ($bytestot >1000) { $bytestot= $bytestot/1000; $tag="M"; } @bytes=split //,$bytes; @bytesrev=(); for ($i=$#bytes, $j=0; $i>=0; $i--, $j++) { if ($j % 3 == 0 and $j!=0) { push @bytesrev, "."; } push @bytesrev, $bytes[$i]; } $bytes=join "",reverse @bytesrev; ; printf "$tag %12s $nom\n",$bytes; }