gpt4 book ai didi

amazon-web-services - 将多个文件从文件夹复制到 s3,不包括少数文件夹

转载 作者:行者123 更新时间:2023-12-05 04:08:02 27 4
gpt4 key购买 nike

我想将一个文件夹中的多个文件从 ec2 复制到 s3 存储桶。

文件夹结构是这样的,

└───data
├───201707
|
|__ new
|
|__ new1

我只想复制 201707 文件夹的内容,所以我使用了以下命令:

aws s3 cp data/ s3://bucket-name/data/201707/ --recursive --exclude 'data/new/*' --exclude 'data/new1/*'

但是 s3 中的输出有一个 new 和 new1 文件夹,排除这些文件夹的正确命令是什么?

最佳答案

--exclude--include 参数用于 s3 aws-cli 子命令采用模式,不仅仅是路径前缀。

--exclude (string) Exclude all files or objects from the command that matches the specified pattern.

来源:https://docs.aws.amazon.com/cli/latest/reference/s3/cp.html

The following pattern symbols are supported.

*: Matches everything
?: Matches any single character
[sequence]: Matches any character in sequence
[!sequence]: Matches any character not in sequence

来源:https://docs.aws.amazon.com/cli/latest/reference/s3/index.html#use-of-exclude-and-include-filters

根据您的示例,正​​确的调用应该是:

aws s3 cp data/ s3://bucket-name/data/201707/ --recursive --exclude 'data/new/*' --exclude 'data/new1/*'

关于amazon-web-services - 将多个文件从文件夹复制到 s3,不包括少数文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48123556/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com