亚马逊S3的球形图案 [英] Glob pattern with amazon s3
问题描述
我想将文件从一个s3存储桶移动到另一个s3存储桶.我只想移动名称以"part"开头的文件.我可以使用java来实现.但是可以使用Amazon CLI来实现.我们可以在CLI中使用GlobPattern吗? 我的对象名称如下: part0000 part0001
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
推荐答案
是的,可以使用--include
和--exclude
选项通过aws CLI实现.
Yes, this is possible through the aws CLI, using the --include
and --exclude
options.
作为示例,您可以使用aws s3 sync
命令来同步零件文件:
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/
您还可以使用带有--recursive
标志的cp
命令:
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/
说明:
-
aws
:aws CLI命令 -
s3
:要与之交互的aws服务 -
sync
:对服务执行的命令 -
--exclude <value>
:要被忽略的UNIX风格的通配符,除非包含语句 -
--include <value>
:要操作的UNIX样式的通配符.
aws
: The aws CLI commands3
: The aws service to interface withsync
: 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.
如文档,您也可以多次指定--include
和--exclude
.
As noted in the documentation, you can also specify --include
and --exclude
multiple times.
这篇关于亚马逊S3的球形图案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!