Skip to content

Instantly share code, notes, and snippets.

@mathew-fleisch
Last active June 7, 2021 16:41
Show Gist options
  • Select an option

  • Save mathew-fleisch/931ee333cecccc54717b92908bcdb3b0 to your computer and use it in GitHub Desktop.

Select an option

Save mathew-fleisch/931ee333cecccc54717b92908bcdb3b0 to your computer and use it in GitHub Desktop.

Revisions

  1. mathew-fleisch revised this gist Jun 7, 2021. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion recursive-directory-sizes.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,12 @@

    get_dirs() {
    dir=$(realpath $1)
    for d in $dir/*/; do if [[ -d $d ]]; then du -sh $d; get_dirs $d; fi; done
    for d in $dir/*/; do
    if [[ -d $d ]]; then
    du -sh $d
    get_dirs $d
    fi
    done
    }

    get_dirs $1
  2. mathew-fleisch created this gist Jun 7, 2021.
    8 changes: 8 additions & 0 deletions recursive-directory-sizes.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    #!/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