我正在启动一个 bash 脚本,该脚本将采用 S3 中的路径(由 ls 命令指定)并将所有文件对象的内容转储到 stdout
。本质上我想复制 cat/path/to/files/*
除了 S3,例如s3cat '/bucket/path/to/files/*'
。查看这些选项时,我的第一个倾向是对临时文件使用 cp
命令,然后使用 cat
命令。
有没有人尝试过这个或类似的,或者是否已经有一个我找不到的命令?
最佳答案
dump the contents of all of the file objects to stdout.
如果您通过 -
作为 aws s3 cp
命令的目的地,您可以完成此操作。
例如,$ aws s3 cp s3://mybucket/stream.txt -
。
您正在尝试做的是这样的事情吗?::
#!/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
关于bash - 如何使用 AWS S3 CLI 将文件转储到 BASH 中的标准输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28330907/