Last active
December 3, 2024 20:06
-
-
Save draeath/69e915f548f5de5da6eca7e7b1033e82 to your computer and use it in GitHub Desktop.
sorted disk usage in human readable units (bash)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo Results for: $(hostname):$(pwd) > ~/du_sorted.txt | |
sudo nice du -xk --exclude=.snapshot | nice sort -nr | nice \ | |
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; | |
}' >> ~/du_sorted.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment