Skip to content

Instantly share code, notes, and snippets.

@zerowebcorp
Last active August 4, 2020 07:12
Show Gist options
  • Save zerowebcorp/f1b2ed41b2603aa331736bae728eabfe to your computer and use it in GitHub Desktop.
Save zerowebcorp/f1b2ed41b2603aa331736bae728eabfe 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
@RadicalPet
Copy link

I think it is Mb (megabits, not megabytes).

@zerowebcorp
Copy link
Author

Isn't megabits represents the speed of the internet connection and megabytes the size of a file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment