Last Updated: February 25, 2016
·
2.978K
· abh1nv

List all folders in descending order of size

List all folders in the current folder in descending order of size of content with human readable folder-sizes.

du -k -d 1 | sort -nr | awk '
     BEGIN {
        split("KB,MB,GB,TB", Units, ",");
     }
     {
        u = 1;
        while ($1 >= 1024) {
           $1 = $1 / 1024;
           u += 1
        }
        $1 = sprintf("%.1f %s", $1, Units[u]);
        print $0;
     }
    '