How can I use wildcards to `cp` a group of files w

2019-03-17 02:19发布

I'm having trouble using * in the AWS CLI to select a subset of files from a certain bucket.

Adding * to the path like this does not seem to work

aws s3 cp s3://data/2016-08* .

2条回答
兄弟一词,经得起流年.
2楼-- · 2019-03-17 03:10

To download multiple files from an aws bucket to your current directory, you can use recursive, exclude, and include flags like this:

aws s3 cp s3://data/ . --recursive --exclude "*" --include "2016-08*"

For more info on how to use these filters: http://docs.aws.amazon.com/cli/latest/reference/s3/#use-of-exclude-and-include-filters

查看更多
Ridiculous、
3楼-- · 2019-03-17 03:13

The Order of the Parameters Matters

The exclude and include should be used in a specific order, We have to first exclude and then include. The viceversa of it will not be successful.

aws s3 cp s3://data/ . --recursive  --include "2016-08*" --exclude "*" 

This will fail because order of the parameters maters in this case. The include is excluded by the *

aws s3 cp s3://data/ . --recursive --exclude "*" --include "2016-08*"`

This one will work because the we excluded everything but later we had included the specific directory.

查看更多
登录 后发表回答