[plug] Handy Script : Treesize

Tim Basten tbasten at gmail.com
Tue Aug 13 08:10:50 UTC 2013


Hi Everyone,

I came across this handy little script which is similar to the windows
application Treesize. Just drop the script into the /bin, change to the
directory you would like to "tresize" and just run treesize.

#/bin/sh
du -k --max-depth=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;
     }

Hope you find this helpful.

Cheers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plug.org.au/pipermail/plug/attachments/20130813/267e1143/attachment.html>


More information about the plug mailing list