Glob pattern with amazon s3

こ雲淡風輕ζ 提交于 2020-01-07 07:11:16

问题


I want to move files from one s3 bucket to another s3 bucket.I want to move only files whose name starts with "part".I can do it by using java.But is it possible to do it with amazon CLI. Can we use GlobPattern in CLI. my object name are like: part0000 part0001


回答1:


Yes, this is possible through the aws CLI, using the --include and --exclude options.

As an example, you can use the aws s3 sync command to sync your part files:

aws s3 sync --exclude '*' --include 'part*' s3://my-amazing-bucket/ s3://my-other-bucket/

You can also use the cp command, with the --recursive flag:

aws s3 cp --recursive --exclude '*' --include 'part*' s3://my-amazing-bucket/ s3://my-other-bucket/

Explanation:

  • aws: The aws CLI command
  • s3: The aws service to interface with
  • sync: The command to the service to do
  • --exclude <value>: The UNIX-style wildcard to ignore, except by include statements
  • --include <value>: The UNIX-style wildcard to act upon.

As noted in the documentation, you can also specify --include and --exclude multiple times.



来源:https://stackoverflow.com/questions/42363027/glob-pattern-with-amazon-s3

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!