AWS CLI在路径中移动带有通配符(星号)的文件

Bra*_*ost 8 amazon-s3 amazon-web-services amazon-data-pipeline

我正在使用AWS数据管道中的活动尝试将文件从s3位置移动到另一个位置.

我使用的命令是:

(aws s3 mv s3://foobar/Tagger/out//*/lastImage.txt s3://foobar/Tagger/testInput/lastImage.txt)
Run Code Online (Sandbox Code Playgroud)

但是我收到以下错误:

A client error (404) occurred when calling the HeadObject operation: Key "Tagger/out//*/lastImage.txt" does not exist
Run Code Online (Sandbox Code Playgroud)

但是,如果我用特定的目录名替换"*",它将起作用.问题是我不会总是知道目录的名称,所以我希望我可以使用"*"作为外卡.

小智 10

AWS S3 CLI中的通配符仅在使用--recursive标志时有效.

所以这对你有用:

aws s3 mv s3://foobar/Tagger/out/ s3://foobar/Tagger/testInput/ --recursive --exclude "*" --include "*/lastImage.txt"
Run Code Online (Sandbox Code Playgroud)

不幸的是,这将在目标位置重新创建整个目录结构,我不能立即确定只需使用AWS CLI即可解决.