Sorting Directories On Size, Human Readable

Posted on April 28, 2007 in Linux

So far i have this:

du -h --max-depth=1 | grep '[0-9]K' | sort -n ; du -h --max-depth=1 | grep '[0-9]M' | sort -n | du -h --max-depth=1 | grep '[0-9]G' | sort -n

To include regular files in this sorting just use du -ah instead...

Edit: A far better version as pointed by deice is:


du -s * | sort -n | cut -f 2- | while read a; do du -hs $a; done