Sorting Directories On Size, Human Readable
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
Technorati Tags: sort, du, grep, directories, human-readable





That wouldn’t work with eg. 1.2G would it ?
My version is:
du -s * | sort -n | cut -f 2- | while read a; do du -hs “$a”; done
This seems to work okay, although it requires doing du twice, in principle. But this isn’t a major problem because due to caching the second run should be lightning fast.
This works also for 1.2G, but your version is nicer :) thx.