Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save diplodata/9afe41bf5c50ca58b7e98ea90e47aa13 to your computer and use it in GitHub Desktop.
Save diplodata/9afe41bf5c50ca58b7e98ea90e47aa13 to your computer and use it in GitHub Desktop.
AWS S3 List all buckets size
for dir in $(aws s3 ls | awk '{print $3'}); do
size=$(aws s3 ls s3://${dir} --recursive | grep -v -E "(Bucket: |Prefix: |LastWriteTime|^$|--)" | awk 'BEGIN {total=0}{total+=$3}END{print total/1024/1024" MB"}');
echo "${dir} => $size" | tee -a disk.txt
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment