Created
September 25, 2017 19:54
-
-
Save codl/879b78bff86f480a1a1d06b4389a48e4 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
set -eufo pipefail | |
SIZE=0 | |
F=$(mktemp --tmpdir b2-bucket-size.json.XXXX) | |
b2 list-file-versions $1 > $F | |
while true; do | |
SIZE=$[$SIZE + $(jq -r '[.files[].contentLength] | add' $F)] | |
NEXT=$(jq -r '.nextFileName' $F) | |
NEXTID=$(jq -r '.nextFileId' $F) | |
[[ $NEXT == 'null' ]] && break | |
b2 list-file-versions $1 $NEXT $NEXTID > $F | |
done | |
echo $SIZE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment