4 ms·
sort supports human values du -sh * | sort -h
by diafygi 10y ago
sort supports human values
du -sh * | sort -h
- diegorbaquero 10y agoNot in Mac :/
- kpil 10y agoThat's BSD's sort, not GNU sort, isn't it?
- oneeyedpigeon 10y agoNot here :( What version of sort are you running?
- e12e 10y agoProbably a recent version of GNU sort. AFAIK "sort -h" dates at least as far back as the version shipped with Debian old-stable.
- oneeyedpigeon 10y agoI'm on macOS 10.12.3, GNU coreutils 5.93, and sort doesn't support the "-h" flag.
- justinsaccount 10y agoYou're using a version of coreutils from over a decade ago. coreutils-5.93.tar.bz2 2005-11-06 09:06
- davejamesmiller 10y agoIt can also be achieved with some Perl: du -h | perl -e 'sub h{%h=(K=>10,M=>20,G=>30);($n,$u)=shift=~/([0-9.]+)(\D)/; return $n*2**$h{$u}}print sort{h($b)<=>h($a)}<>;' Source: http://serverfault.com/a/62422/76878 http://serverfault.com/a/62422/76878
- james2vegas 10y agoset BLOCKSIZE to some power of 1024 when running du