Last active
May 27, 2022 18:49
-
-
Save lewiswalsh/b183e6b702cae9b092991d5c908eb7af to your computer and use it in GitHub Desktop.
List all s3 buckets with size #bash #s3
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 | |
BUCKETS=$(aws s3 ls) | |
while IFS= read -r line | |
do | |
BUCKET=$(echo $line | cut -d " " -f3) | |
SIZE=$(aws s3 ls --summarize --human-readable --request-payer --recursive s3://$BUCKET/ | grep "Total Size" | cut -d ":" -f2) | |
echo "$BUCKET $SIZE" | |
done <<< "$BUCKETS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment