-
-
Save bool-dev/bd6ceed6fc3dc1796b70111bb6221843 to your computer and use it in GitHub Desktop.
Get bucket size and object count by first level prefix (i.e. bucket/prefix1, bucket/prefix2)
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/sh | |
BUCKETNAME=mybucketname; REGION=us-east-1; for prefix in $(aws s3api list-objects --bucket $BUCKETNAME --delimiter '/' --output text --region $REGION |grep COMMONPREFIX |tail -n+2| awk '{print $2}'); do echo "Totals for $prefix"; aws s3 ls --summarize --human-readable --recursive s3://$BUCKETNAME/$prefix --region $REGION ; done |grep Total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment