Page 3 of 3 FirstFirst 123
Results 21 to 23 of 23

Thread: du question: sort by size & show human-readable sizes

  1. #21
    Join Date
    Jul 2006
    Location
    New York City
    Beans
    21
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: du question: sort by size & show human-readable sizes

    final improvement: when sizes are the same, sort by path name. I needed this to ensure stable sort so I can more easily compare e.g. last week's usage with today's.

    Code:
    %byte_order = ( T => 4, G => 3, M => 2, K => 1, k => 1, 0 => 0);
    print map { $_->[0] }
          sort { $byte_order{$b->[1]} <=> $byte_order{$a->[1]} || $b->[2] <=> $a->[2] || $b->[0] cmp $a->[0] }
          map { [ $_, /^\d+\.?\d*([TGMKk0])/, /^(\d+\.?\d*)[TGMKk]/ ] }
          <>;
    dell 1420n

  2. #22
    Join Date
    Sep 2010
    Beans
    9
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: du question: sort by size & show human-readable sizes


  3. #23
    Join Date
    Apr 2007
    Location
    Belgium
    Beans
    148
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: du question: sort by size & show human-readable sizes

    +1

    Quote Originally Posted by garbelini View Post

Page 3 of 3 FirstFirst 123

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •