Skip to content

Instantly share code, notes, and snippets.

@hjhart
Last active November 6, 2017 19:39
Show Gist options
  • Save hjhart/432689a75b358d6c26feb276843c4f72 to your computer and use it in GitHub Desktop.
Save hjhart/432689a75b358d6c26feb276843c4f72 to your computer and use it in GitHub Desktop.

Revisions

  1. hjhart revised this gist Nov 4, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions 1_list_directories.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    # function happily borrowed from https://unix.stackexchange.com/a/259254
    bytesToHuman() {
    b=${1:-0}; d=''; s=0; S=(Bytes {K,M,G,T,E,P,Y,Z}iB)
    while ((b > 1024)); do
  2. hjhart revised this gist Nov 4, 2017. 3 changed files with 10 additions and 30 deletions.
    File renamed without changes.
    10 changes: 10 additions & 0 deletions 2_output
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    .joyent/ 41693 40.71 KiB
    backup/ 62206189 59.32 MiB
    backups/ 4732683606342 4.30 TiB
    cores/ 612648223 584.26 MiB
    demo/ 22077652 21.05 MiB
    images/ 298759686 284.91 MiB
    postgres/ 33733185216 31.41 GiB
    sitemaps/ 6346928762 5.91 GiB
    staging/ 5547741 5.29 MiB
    tmp/ 163482942 155.90 MiB
    30 changes: 0 additions & 30 deletions Output
    Original file line number Diff line number Diff line change
    @@ -1,30 +0,0 @@
    bytesToHuman() {
    b=${1:-0}; d=''; s=0; S=(Bytes {K,M,G,T,E,P,Y,Z}iB)
    while ((b > 1024)); do
    d="$(printf ".%02d" $((b % 1024 * 100 / 1024)))"
    b=$((b / 1024))
    let s++
    done
    echo "$b$d ${S[$s]}"
    }


    mkdir manta_contents
    for dir in $(mls | grep -v logs)
    do echo $dir
    mkdir -p manta_contents/$dir
    mls -l $dir >> manta_contents/$(echo $dir)/files
    for subdir in $(mfind -t d /wanelo/stor/$dir)
    do
    mls -l $subdir >> manta_contents/$(echo $dir)/files
    done
    done


    for dir in $(mls | grep -v logs)
    do
    bytes=$(cat manta_contents/$dir/files | awk '{ print $4 }' | paste -sd+ - | bc)
    echo $dir $bytes $(bytesToHuman $bytes)
    done
    done

  3. hjhart created this gist Nov 4, 2017.
    30 changes: 30 additions & 0 deletions Output
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    bytesToHuman() {
    b=${1:-0}; d=''; s=0; S=(Bytes {K,M,G,T,E,P,Y,Z}iB)
    while ((b > 1024)); do
    d="$(printf ".%02d" $((b % 1024 * 100 / 1024)))"
    b=$((b / 1024))
    let s++
    done
    echo "$b$d ${S[$s]}"
    }


    mkdir manta_contents
    for dir in $(mls | grep -v logs)
    do echo $dir
    mkdir -p manta_contents/$dir
    mls -l $dir >> manta_contents/$(echo $dir)/files
    for subdir in $(mfind -t d /wanelo/stor/$dir)
    do
    mls -l $subdir >> manta_contents/$(echo $dir)/files
    done
    done


    for dir in $(mls | grep -v logs)
    do
    bytes=$(cat manta_contents/$dir/files | awk '{ print $4 }' | paste -sd+ - | bc)
    echo $dir $bytes $(bytesToHuman $bytes)
    done
    done

    28 changes: 28 additions & 0 deletions list_directories.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    bytesToHuman() {
    b=${1:-0}; d=''; s=0; S=(Bytes {K,M,G,T,E,P,Y,Z}iB)
    while ((b > 1024)); do
    d="$(printf ".%02d" $((b % 1024 * 100 / 1024)))"
    b=$((b / 1024))
    let s++
    done
    echo "$b$d ${S[$s]}"
    }

    mkdir manta_contents
    for dir in $(mls)
    do echo $dir
    mkdir -p manta_contents/$dir
    mls -l $dir >> manta_contents/$(echo $dir)/files
    for subdir in $(mfind -t d /wanelo/stor/$dir)
    do
    mls -l $subdir >> manta_contents/$(echo $dir)/files
    done
    done

    for dir in $(mls)
    do
    bytes=$(cat manta_contents/$dir/files | awk '{ print $4 }' | paste -sd+ - | bc)
    echo $dir $bytes $(bytesToHuman $bytes)
    done
    done