Prints du Unix command sorted by filesize, greater first. Useful when you finish space on your hard-drive and you want to know which dir takes up the most space. I searched the man pages for such an option but i found nothing.
du|perl -lpe 'push @_, [split]}{print "@$_" for sort{$b->[0]<=>$a->[0] +}@_'|less

Replies are listed 'Best First'.
Re: Sorted "du"
by giulienk (Curate) on Feb 26, 2002 at 22:38 UTC
    Well, i notice just now the utility sort, i suppose it comes standard with most Unix flavours:
    du|sort -gr|less
    Well, but that's not perlish at all! And anyway TIMTOWTDI :)
    $|=$_='1g2i1u1l2i4e2n0k',map{print"\7",chop;select$,,$,,$,,$_/7}m{..}g
      On SysV, I am not aware of th -g option for sort, rather I use -n. Everyone tends to forget this great little command:)
      du|sort -nr|less
Re: Sorted "du"
by fundflow (Chaplain) on Feb 26, 2002 at 23:20 UTC