AWS CLI moving file with wildcard (asterisk) in path
Asked Answered
N

1

17

I am attempting to move a file, from on s3 location to another, using an activity in a AWS data pipeline.

The command I am using is:

(aws s3 mv s3://foobar/Tagger/out//*/lastImage.txt s3://foobar/Tagger/testInput/lastImage.txt)

But I receive the following error:

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

But, if I replace the "*" with the specific directory name, it will work. The problem is I won't always know the name of the directory, so I was hoping I could use the "*" as a wild card.

Noelyn answered 25/7, 2015 at 18:6 Comment(1)
AWS SDK does not support wildcards. Instead, you can search based on prefix (stuff before the wildcard). Then, you could grep the results for those ending in /lastImage.txtUndersized
I
26

Wildcards in the AWS S3 CLI only work when using the --recursive flag.

So this should work for you:

aws s3 mv s3://foobar/Tagger/out/ s3://foobar/Tagger/testInput/ --recursive --exclude "*" --include "*/lastImage.txt"

Unfortunately, this will recreate the entire directory structure in your target location, and I'm not immediately sure that can be solved by just using the AWS CLI.

Isle answered 21/8, 2015 at 14:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.