Skip to content

Instantly share code, notes, and snippets.

@molotovbliss
Created June 15, 2019 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save molotovbliss/9c2f4c864afb9547b7cf4d6c665a0284 to your computer and use it in GitHub Desktop.
Save molotovbliss/9c2f4c864afb9547b7cf4d6c665a0284 to your computer and use it in GitHub Desktop.
Basic treesize bash script with du & better defaults
#/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