vtbiggi
vtbiggi

Reputation: 183

Unknown Options when Using aws s3 mv

I am getting the error message

"Unknown options: s3://mybucket/"

when using the following set of commands to mv files to S3. The output that I am getting from echo $b is exactly what I am expecting so I know I am targeting the correct file. The error occurs on the lineaws s3 mv ...

tag=$( tail -n 2 /var/log/cloud-init-output.log )
if [[ ${tag} == *"Processed"* ]]; then
    b=${tag##*"from"}
    b=${b%%.*}  # retain the part before the colon
    aws s3 mv myfolder/ s3://mybucket/ --recursive --exclude "*" --include "$b.txt"
fi

After messing around with it for a long time, I believe the $b variable in the mv command is the issue because it will work if I substitute the output of echo $bfor $b in $b.txt. However, I cannot figure out how to fix it.

Here is the output when I run aws --version:

aws-cli/1.14.8 Python/2.7.14 Linux/4.14.47-64.38.amzn2.x86_64 botocore/1.8.12

which is the latest version and I have already tried running (I have python3 installed):

pip3 install --upgrade awscli

I know wildcards are weird with the aws-cli but I don't see why I would get an error using a variable. Thanks in advance.

Upvotes: 3

Views: 20999

Answers (1)

vtbiggi
vtbiggi

Reputation: 183

Instead of using --exclude "*" --include "$b.txt", I just used aws s3 mv myfolder/"$b.txt" s3://mybucket/. I'm pretty sure I tried that same thing earlier without the "" around $b.txt and it didn't work because there was a whitespace in front of the variable.

Upvotes: 5

Related Questions