Last active
October 15, 2015 18:32
-
-
Save schen1628/c3948ae79e2a88f40acb to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# | |
# This script goes through each bucket in s3. It counts number of objects in a bucket and sum up their size. | |
# It also prints out the ACLs for the bucket. | |
# | |
for bucket in `aws s3 ls | awk '{print $3}'` | |
do | |
aws s3 ls s3://$bucket --recursive | | |
awk -v bucket=$bucket 'BEGIN {total=0} | |
BEGIN {count=0} {total+=$3} {count++} | |
END {print bucket"\t"count"\t"total/1024/1024/1024}' | |
aws s3api get-bucket-acl --bucket $bucket --output text | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment