Skip to content

Instantly share code, notes, and snippets.

@lewiswalsh
Last active May 27, 2022 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lewiswalsh/b183e6b702cae9b092991d5c908eb7af to your computer and use it in GitHub Desktop.
Save lewiswalsh/b183e6b702cae9b092991d5c908eb7af to your computer and use it in GitHub Desktop.
List all s3 buckets with size #bash #s3
#!/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