Top ten disk space hogs in current folder

du -cks *|sort -rn|head -11|awk '{printf "%-8.2f MiB\t%s\n", $1/1024, $2}'

NB: first item is the total size, so it outputs eleven lines.

Update: a better version is this one:

du -cks *|sort -rn|head -11|awk '{printf "%-8.2f MiB\t", $1/1024;\
for(i=2; i<=NF; i++) {printf " %s", $i}; printf "\n"}'

... as it takes into account file names with spaces in them. You may also want to squeeze in a BEGIN { FS = " " } at the beginning, so as to prevent tabs from being considered as field separators.

This entry was posted in /dev/null, Bash, EN, Linux, Unix and unixoid. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *