A repository of tips and tricks (in both English and French) curated by Mirego’s engineering team.
  • aws

Calculate the size of an AWS S3 bucket or directory

You can get the total size of an AWS S3 bucket using a GUI tool or via AWS console, right?

How about when you don’t want to use any of that and rather use a clever one-liner command?

$ AWS_ACCESS_KEY_ID=AWS_SECRET_ACCESS_KEY=… aws s3 ls --summarize --recursive --human-readable s3://<bucket>/<directory>/

<lots of files>

Total Objects: 69224
   Total Size: 28.5 GiB

That’s it!