0

I have a nested "folder"/object structure in my S3 bucket:

myBucket/level1/level2/file1.txt
myBucket/level1/level2/file2.txt
...

Is there any way with aws s3 ls or aws s3api to list the size of each "folder"/object on level2?

Thanks!

Paolo
  • 21,270
  • 6
  • 38
  • 69
Alec
  • 100
  • 1
  • 10

1 Answers1

1

You can use the following command:

aws s3 ls s3://myBucket/level1/level2/ --recursive --summarize | awk 'BEGIN{ FS= " "} /Total Size/ {print $3}'

It will print the sum of the sizes, in bytes, of all files under level2.

Paolo
  • 21,270
  • 6
  • 38
  • 69