in reply to Re: Re: finding top 10 largest files
in thread finding top 10 largest files

Ugh! Yep, you're right, my bad... only, the code is too long for my liking. Can it be shorter? Could I use the operating system to pare down the code a bit by pre-gathering a list of all files? Something like

my @files = (reverse sort `dir /A-D /S`)[0..9];
In DOS, or ... (big pause)...
Aw shoot, in DOS the solution isn't even perl:
dir /A-D /O-S /S
That recursively lists all files from the current working directory on, sorted by largest file first. I imagine there's a combination of opts to ls that will do the same thing, eh? Maybe
ls -alSR (which doesn't sort across directories) ls -alR | sort -k 5 (maybe?) (Except those don't suppress the directory names. Hmmm.)

Sorry, I meant to write perl, but it came out rather OS-specific... but it's a lot smaller than the perl solution. Is that Appeal To False Laziness?

Replies are listed 'Best First'.
Re: Re: Re: Re: finding top 10 largest files
by QM (Parson) on Feb 04, 2004 at 00:22 UTC
    dir /A-D /O-S /S
    Good try, but that only sorts them within directories. Files are still grouped by directories first, then sorted by filesize. [At least, not on my win2K, ver 5.00.] -QM

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

      ++QM

      That's what I get for posting off the cuff. Still, there ought to be a way to leverage such listings for sorting purposes -- the filesize is listed before the filename: all you'd have to do in the DOS world is lop off the timestamps in front and tweak a bit, then perl's sort() should work like a charm. Nice and compartmentalized, yes?