[PLUG] List ten biggest files with du

Sandy Herring sandy at herring.org
Tue Oct 14 18:14:49 UTC 2008


Circa 10:04:42 on Tue, 14 Oct 2008, Randal L. Schwartz wrote: 
> >>>>> "Sandy" == Sandy Herring <sandy at herring.org> writes:
> 
> Sandy> require 'find.pl';
> 
> That is *ancient*.  A modern one with File::Find would look like:
> 
>     my $N = 10; # ok, so it's not a command line arg :)
> 
>     use File::Find;
> 
>     my %size;
>     find(sub {
>       $size{$File::Find::name} = -s _ if not -l and -f _;
>     }, @ARGV);
>     @sorted = sort { $size{$b} <=> $size{$a} } keys %size;
>     for (@sorted[0..($n-1)]) {
>       printf
>         "%40s, %5dK, last accessed %3d days ago\n",
>         $_ , (-s)/1024, -A _;
>     }
> 
> Untested, but I often get this right.

the n in the for loop needs to be uppercased - then it work.

Thanks!
Sandy
-- 
Sandy Herring, RHCE                        o              sandy at herring.org
Peck of Pickled Pisces               __  o               http://herring.org/
*nix || Web authoring questions?  |\/ o\  o  http://herring.org/finger.html
->http://herring.org/techie.html  |/\__/     http://herring.org/pub-key.asc



More information about the PLUG mailing list