Skip to content

Instantly share code, notes, and snippets.

@tafkey
Last active February 9, 2022 09:17
Show Gist options
  • Save tafkey/4736336 to your computer and use it in GitHub Desktop.
Save tafkey/4736336 to your computer and use it in GitHub Desktop.
A simple “treesize” shell script for Linux (adopted from Andrew's blog, http://blog.aclarke.eu)
#/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;
}
'
@rkhyd
Copy link

rkhyd commented Jan 2, 2018

works well..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment