How do you pipe the result of s3cmd get to a var?

左心房为你撑大大i 提交于 2019-12-08 06:45:18

问题


I need to get an image from S3, process it on an ec2, and save it to a different folder on S3. I would like to not save the file to ec2 during the process.

Is it possible to pipe the result of "s3cmd get s3://bucket/image" to a var? It does not seem to print to standard output?


回答1:


It would be better if you could show which output produce s3cmd in your case. But if you really want to save the output of the command to a variable you do it this way:

$ a=$(s3cmd get s3://bucket/image)

When you want to save stderr also, you make:

$ a=$(s3cmd get s3://bucket/image 2>&1)

And when only stderr:

$ a=$(s3cmd get s3://bucket/image 2>&1 > /dev/null)


来源:https://stackoverflow.com/questions/11118671/how-do-you-pipe-the-result-of-s3cmd-get-to-a-var

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!