【发布时间】:2019-07-29 05:09:14
【问题描述】:
我正在使用:
aws s3api list-objects --endpoint-url https://my.end.point/ --bucket my.bucket.name --query 'Contents[].Key' --output text
获取存储桶中的文件列表。
aws s3api list-objectdocumentation page 表示此命令最多返回 1000 个对象,但是我注意到在我的情况下它返回我存储桶中所有文件的名称。例如,当我运行以下命令时:
aws s3api list-objects --endpoint-url https://my.end.point/ --bucket my.bucket.name --query 'Contents[].Key' --output text | tr "\t" "\n" | wc -l
我得到 13512 显示,这意味着返回了超过 13000 个文件名。
我是不是错过了什么?
我使用以下 aws cli 版本:
aws-cli/1.10.57 Python/2.7.3 Linux/3.2.0-4-amd64 botocore/1.4.47
【问题讨论】:
-
使用
--query时如何限制结果? -
我使用
head解决了我的问题:aws s3api list-objects --bucket $bucket_change_class --query 'Contents[?StorageClass==STANDARD].[Key]' --output text | head -n 2
标签: linux amazon-web-services amazon-s3