【问题标题】:aws-cli command in windows to get the latest object from s3 bucketWindows 中的 aws-cli 命令从 s3 存储桶中获取最新对象
【发布时间】:2019-11-11 10:48:34
【问题描述】:

我在我的 Windows 机器中使用 aws cli 命令从 s3 存储桶获取最新文件。

aws s3 ls s3://Bucket-name --recursive | sort |tail -n 1

这里是按照日期排序的方式列出所有文件:

aws s3 ls s3://Bucket-name --recursive | sort 

但是写完整的命令会报错:

'Tail 未被识别为内部或外部命令'。

tail 或完整命令是否有其他替代方法。

【问题讨论】:

    标签: amazon-web-services amazon-s3 aws-cli tail


    【解决方案1】:

    AWS CLI 允许在 --query 参数中使用 JMESPath 表达式。

    此命令显示最近更新的对象:

    aws s3api list-objects --bucket my-bucket --query 'sort_by(Contents, &LastModified)[-1].Key' --output text
    

    基本上是在说:

    • LastModified排序
    • 获取最后一个[-1] 条目
    • 显示密钥(文件名)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-05-06
      • 1970-01-01
      • 2021-10-14
      • 1970-01-01
      • 2017-05-26
      • 1970-01-01
      • 2020-12-16
      相关资源
      最近更新 更多