And yet annother possibility I found in my code stash.
It lists the top n filesizes with all files having these sizes:
#!/usr/bin/perl use strict; my ($dir_init, $top_n) = @ARGV; my (@ls, @dirs, %top, $size, $obsolete_size); my $sep = "~" x 80; my $form = "%20s %s\n"; my $min_size = 0; my $files = 0; push(@dirs, $dir_init);
foreach my $directory (@dirs) { opendir (DIR, $directory) or die ("Can't open dir: '$directory'.\n +Reason: $!"); @ls = readdir(DIR); closedir (DIR); FILE: foreach my $file (@ls) { next if ($file =~ m/^\.\.?$/); $files++; SWITCH: { if (-d "$directory/$file") { push(@dirs, "$directory/$file"); last SWITCH; } if (-l "$directory/$file") { last SWITCH; } if (-f "$directory/$file") { $size = (-s "$directory/$file"); if ($size >= $min_size) { push (@{$top{$size}}, "$directory/$file"); if ($size > $min_size && scalar(keys %top) > $top_ +n) { ($obsolete_size,$min_size) = (sort {$a <=> $b +} keys %top)[0,1]; delete($top{$obsolete_size}); } } last SWITCH; } else { print "\n$file\tis of UNKNOWN type"; } } } } print $sep . "\n"; print "Total number of files examined: $files\n"; print $sep . "\n"; print "List of top " . $top_n . " sized files within " . $dir_init . " + :\n"; foreach my $k (sort {$b <=> $a} keys %top) { print delim1000($k) . "\n"; foreach (@{$top{$k}}) { print "\t$_\n"; } } print $sep . "\n"; sub delim1000 { my $text = reverse $_[0]; $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g; return scalar reverse $text; }
call it like:
perl fszTop10.pl /u2/integ 10
and the output looks like:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Total number of files examined: 2331 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ List of top 10 sized files within /u2/integ/t096351 : 23,836,788 /u2/integ/t096351/tmp/PDF/NV61DE.PDF 5,731,355 /u2/integ/t096351/test/gsp_toCMT.tar.gz 180,042 /u2/integ/t096351/jcs553_functions_ALL.sql.v1 /u2/integ/t096351/jcs553_functions_ALL.sql.v2 /u2/integ/t096351/jcs553_functions_ALL.sql.copy 105,520 /u2/integ/t096351/ccm_ui.log 56,216 /u2/integ/t096351/ccm_eng.log 24,072 /u2/integ/t096351/dead.letter 14,506 /u2/integ/t096351/.ccm.ini 11,492 /u2/integ/t096351/.sh_history 5,111 /u2/integ/t096351/.dtprofile 2,561 /u2/integ/t096351/.Xauthority ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

pelagic

Update
I had to fix a bug I found, as I was using the script again.

In reply to Re: finding top 10 largest files by pelagic
in thread finding top 10 largest files by bfdi533

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.