Created
January 24, 2016 19:25
-
-
Save tomlobato/d8b83c6ab2fdfc0d066e to your computer and use it in GitHub Desktop.
Find Amazon S3 bucket usage
This file contains hidden or 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 s3size() { | |
for path in $*; do | |
size=$(aws s3 ls "s3://$path" --recursive | grep -v -E "(Bucket: |Prefix: |LastWriteTime|^$|--)" | awk 'BEGIN {total=0}{total+=$3}END{printf "%.2fGb\n", (total/1024/1024/1024)}'); | |
echo "[s3://$path]=[$size]"; | |
done; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment