Ordena el resultado del comando du

Tuesday, June 28, 2011 18:33
Posted in category Linux
du -k | 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;
     }
    ' > /tmp/sort_file.txt
You can leave a response, or trackback from your own site.

Leave a Reply