Skip to content

Instantly share code, notes, and snippets.

@jybaek
Created February 26, 2016 08:46
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 jybaek/fc36224ad9f40c74020e to your computer and use it in GitHub Desktop.
Save jybaek/fc36224ad9f40c74020e to your computer and use it in GitHub Desktop.
Check directory size
#!/bin/sh
DEPTH=1
if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "help" ] || [ "$1" = "h" ] ;then
cat <<EOF
======================================================
.du usage : .du {check directory maxdepth} (default 1)
======================================================
e.g.
1) .du
2) .du 3
EOF
exit 255
fi
if [ -n "$1" ];then
DEPTH=$1
fi
DIRLIST=$(find ./ -maxdepth $DEPTH -type d 2>/dev/null)
if [ -z "$DIRLIST" ]; then
echo "Input: $DEPTH: use number!"
exit 255
fi
for DIR in $DIRLIST;do
du -sh $DIR
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment