Thanks for this! Found this article after a short Google search on the topic :)
One thing I note is that the file size reported is in Gibibytes — I had to convert to Gigabytes in order to get the figure more commonly shown when hitting CMD + I on a file or directory.
Using this method to play a bit of hard drive tetris and figure out the most space efficient way to store a bunch of large directories across a couple external drives, and this accurate way of getting directory sizes without having to manually CMD + I every directory to get its size is a life saver!
I use the following alias:
alias duf='du -sk * | sort -n | while read size fname; do for unit in k M G T P E Z Y; do if [ $size -lt 1024 ]; then echo -e "${size}${unit}\t${fname}"; break; fi; size=$((size/1024)); done; done'
Picked it up from http://www.earthinfo.org/linux-disk-usage-sorted-by-size-and-human-readable/
which no longer exists. :-(