I'm starting a bash script which will take a path in S3 (as specified to the ls command) and dump the contents of all of the file objects to stdout
. Essentially I'd like to replicate cat /path/to/files/*
except for S3, e.g. s3cat '/bucket/path/to/files/*'
. My first inclination looking at the options is to use the cp
command to a temporary file and then cat
that.
Has anyone tried this or similar or is there already a command I'm not finding which does it?
You can use cp to copy the files from an s3 bucket to your local system. Use the following command: $ aws s3 cp s3://bucket/folder/file.txt .
dump the contents of all of the file objects to stdout.
You can accomplish this if you pass -
for destination of aws s3 cp
command. For example, $ aws s3 cp s3://mybucket/stream.txt -
.
What you're trying to do is something like this? ::
#!/bin/bash BUCKET=YOUR-BUCKET-NAME for key in `aws s3api list-objects --bucket $BUCKET --prefix bucket/path/to/files/ | jq -r '.Contents[].Key'` do echo $key aws s3 cp s3://$BUCKET/$key - | md5sum done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With