Find disk space usage

From Wiki
Jump to: navigation, search

To find space used sorted by size on CentOS 5 or OS X you will need to use awk to sort output.

du -hx * | awk '{printf "%s %08.2f\t%s\n", index("KMG", substr($1, length($1))), substr($1, 0, length($1)-1), $0}' | sort -r|cut -f2,3

CentOS 6 includes the "sort -h" command which makes this much simpler.

du -hsxc * 2>/dev/null | sort -h