【问题标题】:Using s3cmd, how do I retreived the newest folder by "Last modfied" date in an s3 directory使用 s3cmd,如何在 s3 目录中按“上次修改”日期检索最新文件夹
【发布时间】:2020-05-19 13:38:51
【问题描述】:

我有一个目录,其中包含使用时间戳创建的文件夹名称的文件夹。我想使用 s3cmd 查找具有最新“上次修改”值的文件。如果这是不可能的,那么这些先前问题的解决方案是否可行? looking for s3cmd download command for a certain date

Using S3cmd, how do I get the first and last file in a folder?

s3cmd 可以本地执行此操作,还是我必须检索所有文件夹名称并对其进行排序?

【问题讨论】:

  • 旁注:这些天,建议使用官方AWS CLI,而不是s3cmd

标签: amazon-s3 s3cmd


【解决方案1】:

使用AWS Command-Line Interface (CLI),您可以列出最近的文件:

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

第一个(最旧的)对象是:

aws s3api list-objects --bucket my-bucket-name --prefix folder1/folder2/ --query 'sort_by(Contents, &LastModified)[0].Key' --output text

【讨论】:

  • 感谢您的解决方案。 --query 需要移到前缀之后。你能为未来的读者更正吗?
  • 哎呀!现已修复。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-04-06
  • 2023-04-09
  • 1970-01-01
  • 2020-03-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多