home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / linux / utilities-general / largest20 < prev    next >
Text File  |  2015-01-21  |  434b  |  13 lines

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