home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2013 / 2013.06.linuxmafia.com / linuxmafia.com / pub / linux / utilities-general / largest20 < prev    next >
Encoding:
Text File  |  2005-05-16  |  385 b   |  12 lines

  1. #!/usr/bin/perl -w
  2. # You can alternatively just do:  
  3. # find . -xdev -type f -print0 | xargs -r0 ls -l | sort -rn +4 | head -20
  4. use File::Find;
  5.  
  6. @ARGV = $ENV{ PWD } unless @ARGV;
  7. find ( sub { $size{ $File::Find::name } = -s if -f; }, @ARGV );
  8. @sorted = sort { $size{ $b } <=> $size{ $a } } keys %size;
  9. splice @sorted, 20 if @sorted > 20;
  10. printf "%10d %s\n", $size{$_}, $_ for @sorted
  11.  
  12.