'S3 Restore Recursive command failing on whitespaces in file names

Got a command which sets off a restore from glacier recursively from the folder I point it at

Found from here

aws s3 ls s3://<bucket_name>/<path> --recursive --profile <s3username> | \
awk '{print substr($0, index($0, $4))}' | \
xargs -L 1 aws s3api restore-object --bucket <bucket_name> \
--restore-request '{"Days":1,"GlacierJobParameters":{"Tier":"Standard"}}' \
--profile <s3username> --key

This works for my S3 folders i'm trying to restore where the files don't have whitespace in them but otherwise I get this output

Unknown options: Foo, Bar, Word.pdf

Any help would be appreciated

Thank you in advance



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source