Created
June 15, 2019 02:07
-
-
Save molotovbliss/9c2f4c864afb9547b7cf4d6c665a0284 to your computer and use it in GitHub Desktop.
Basic treesize bash script with du & better defaults
This file contains hidden or 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/sh | |
#set -x #echo on | |
if [ "$1" == "-h" ]; then | |
echo "usage: treesize [depth (0)] [sizelimit (1MB)]" | |
echo "" | |
echo "example: treesize 3 20G" | |
echo "" | |
echo "Show all folders larger than 20GBs & only scan 3 directories in deep" | |
echo "defaults are 0 depth, 1MB limit equiv to treesize 0 1MB" | |
exit | |
fi | |
if [ "$1" == "" ]; then | |
DEPTH="-d0" | |
else | |
DEPTH="-d$1" | |
fi | |
if [ "$2" == "" ]; then | |
SIZE="-t1MB" | |
else | |
SIZE="-t$2" | |
fi | |
du -hx $SIZE $DEPTH * | sort -h; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
POSIX-compliant
/bin/sh