Last active
November 6, 2017 19:39
-
-
Save hjhart/432689a75b358d6c26feb276843c4f72 to your computer and use it in GitHub Desktop.
Joyent Manta, list directories and their recursive size within
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To dive deeper into a subdirectory,