jojo
jojo

Reputation: 331

aws s3 ls filter storage class(STANDARD)

How to list files but I want to list all standard class only.

I want to exclude glacier class.

Currently here is my command:

aws s3 ls s3://Videos/Action/ --human-readable --summarize

Upvotes: 11

Views: 8774

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269400

The aws s3 ls command doesn't display the Storage Class, but you can do it with this command:

aws s3api list-objects-v2 --bucket Videos --prefix Action --query "Contents[?StorageClass=='STANDARD'].Key" --output text

The output is tab-separated, so you may have to massage the output to get it in your desired format, eg:

aws s3api list-objects-v2 --bucket Videos --prefix Action --query "Contents[?StorageClass=='STANDARD'].Key" --output text | sed 's/\t/\n/g'

To gain an understanding of how to selectively use the --query command, see:

Upvotes: 24

Related Questions