in reply to Find the n biggest files
A number of years ago, I modified the 'largest20' script created by Randal Schwartz for my purposes. It's easy enough to tweak it to do what you want:
#!/usr/bin/perl -w use File::Find; die "$0 <count> [dir]\n" unless @ARGV >= 1; my %size; my $count = $ARGV[0]; my $search = $ARGV[1] || $ENV{PWD}; find (sub {$size{$File::Find::name} = -s if -f;}, $search); my @sorted = sort {$size{$b} <=> $size{$a}} keys %size; splice @sorted, $count if @sorted > $count; printf "%10d %s\n", $size{$_}, $_ for @sorted
-- I hate storms, but calms undermine my spirits. -- Bernard Moitessier, "The Long Way"
|
|---|