You could use the core File::Find module and the stat function to scan a directory looking for the file taking up most disk blocks (512 bytes on many file systems though not all). Running the following code in my "Downloads" directory finds that a large CentOS ISO is the guilty culprit.

$ perl -MFile::Find -Mstrict -Mwarnings -E ' my %largest = ( name => q{}, size => 0 ); find( sub { my $blocks = ( stat )[ 12 ]; do { $largest{ name } = $File::Find::name; $largest{ size } = $blocks; } if $blocks > $largest{ size }; }, q{.} ); say qq{$largest{ name } - $largest{ size } blocks};' CentOS-5.10-x86_64-bin-DVD-1of2.iso - 9125976 blocks $

I hope this is helpful.

Update: Substituted $File::Find::name for $_ to store the full path rather than just the file name.

Cheers,

JohnGG


In reply to Re: find biggest file and use awk by johngg
in thread find biggest file and use awk by mxtime

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.