Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Find the n biggest files

by oko1 (Deacon)
on Feb 09, 2012 at 20:55 UTC ( [id://952844]=note: print w/replies, xml ) Need Help??


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"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://952844]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-24 13:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found