如何使用AWS S3 CLI将文件转储到BASH中的stdout? [英] How to use AWS S3 CLI to dump files to stdout in BASH?
问题描述
我正在启动一个bash脚本,它将在S3中采用一个路径(已指定为
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?
推荐答案
将所有文件对象的内容转储到stdout.
dump the contents of all of the file objects to stdout.
如果将-
传递给aws s3 cp
命令的目标,则可以完成此操作.
例如,$ aws s3 cp s3://mybucket/stream.txt -
.
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
这篇关于如何使用AWS S3 CLI将文件转储到BASH中的stdout?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!