Skip to content

Instantly share code, notes, and snippets.

@mathew-fleisch
Last active June 7, 2021 16:41
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 mathew-fleisch/931ee333cecccc54717b92908bcdb3b0 to your computer and use it in GitHub Desktop.
Save mathew-fleisch/931ee333cecccc54717b92908bcdb3b0 to your computer and use it in GitHub Desktop.
Get the size of each directory recursively with du -sh
#!/bin/bash
get_dirs() {
dir=$(realpath $1)
for d in $dir/*/; do
if [[ -d $d ]]; then
du -sh $d
get_dirs $d
fi
done
}
get_dirs $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment