LinuxMatt has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use Cwd; use File::Find; no warnings 'File::Find'; my ($max,$name,$n) = (0,0,0); sub scanfile { return unless -f; # only files return unless -r; # readable return if -l; # not symlinks $n++; print "." unless ($n % 400); # "progress bar" my $sz = -s; if ($max < $sz) { # save biggest $max = $sz; $name = $File::Find::name; } } print "Scanning..."; $|=1; # flush output find(\&scanfile, cwd); # start in current directory recursively printf("\nBiggest: %d kb %s\n",$max/1024,$name);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Find the n biggest files
by Eliya (Vicar) on Feb 09, 2012 at 21:35 UTC | |
|
Re: Find the n biggest files
by oko1 (Deacon) on Feb 09, 2012 at 20:55 UTC | |
|
Re: Find the n biggest files
by Anonymous Monk on Feb 09, 2012 at 21:35 UTC | |
by salva (Canon) on Feb 10, 2012 at 08:57 UTC |