Here's a script that sorts du, even with the -h switch.
(it knows 1G > 1M).
use like du -h dir/* | ./du-sort.pl
-- file: du-sort.pl --
#!/usr/bin/perl
use warnings;
use strict;
my @sary;
while(<>){
chomp;
/^(\d+(?:.\d+)?)([KMG]?)\s+(.+)$/ or die "Huh? Bad string: |$_|\n";
my ($hrs, $size, $unit, $file) = ("$1$2", $1, $2, $3);
for($size){
last if $unit eq '';
$size *= 1024;
last if $unit eq 'K';
$size *= 1024;
last if $unit eq 'M';
$size *= 1024;
}
push @sary, [$size, $hrs, $file];
}
@sary = sort { $a->[0] <=> $b->[0] } @sary;
for(@sary){
printf "%-8s%s\n", $_->[1], $_->[2];
}
__END__
(Um, sorry if this doesn't answer the question, but I had it lying
around in my ~/bin...
It might be possible to do this in shell, but shells are annoying
because of the quoting issue)
-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.
This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 19:57:10 EDT