Created
February 9, 2017 14:04
-
-
Save 2matzzz/88dba42fb6080b9d1b2972cb395b351d to your computer and use it in GitHub Desktop.
s3calc
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 | |
regex='(s3)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]' | |
if [[ $@ =~ $regex ]] | |
then | |
aws s3 ls $@ --recursive | grep -v -E "(Bucket: |Prefix: |LastWriteTime|^$|--)" | awk 'BEGIN {total=0}{total+=$3}END{print total/1024/1024/1024" GB"}' | |
else | |
echo "format err, input e.g. s3://bucket/path/to/calc" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment