Skip to content

Instantly share code, notes, and snippets.

@jeremy5189
Created April 6, 2017 07:56
Show Gist options
  • Save jeremy5189/7e947b1315c0af7798e5d1c0d12322d1 to your computer and use it in GitHub Desktop.
Save jeremy5189/7e947b1315c0af7798e5d1c0d12322d1 to your computer and use it in GitHub Desktop.
#/bin/sh
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;
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment