Afas
Afas

Reputation: 806

How do I list files of a amazon s3 bucket that are under a specific size using the CLI?

For example, if I want to filter the files by their name, I would do:

$ aws s3api list-objects --bucket bucket-name --query "Contents[?contains(Key, 'key-name')]"

I'm looking for a similar command to filter the size of these files, using the "<" and ">" operators.

Upvotes: 1

Views: 2985

Answers (1)

Afas
Afas

Reputation: 806

I found out what was my mistake. I was using single quote instead of ` and therefore it wasn't working. The answer to the question is:

aws s3api list-objects --bucket bucket-name --query 'Contents[?Size<`2000`]'

Upvotes: 4

Related Questions