本文介绍了如何将AWS CLI的输出保存在变量中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将一个AWS CLI的输出保存在一个变量中,并在另一个AWS CLI中使用该变量,如下所示:
I want to save output of an AWS CLI in a variable and use that variable in another AWS CLI, what I did is as follows:
taskarn= aws ecs list-tasks --cluster mycluster --service-name "myService" --region "eu-west-1" --output text | grep "arn" | tr -d '"'
echo $taskarn; //empty
aws ecs stop-task --cluster mycluster --task $taskarn --region "eu-west-1"
当我回显$ taskarn时,它为空.
when I echo $taskarn, it is empty.
任何帮助将不胜感激.
推荐答案
我使用了以下命令,效果很好:
I used the following command and it works fine:
taskarn=$(aws ecs list-tasks --cluster mycluster --service-name "myservice" --region "eu-west-1" | grep "arn" | tr -d '"')
echo $taskarn;
aws ecs stop-task --cluster mycluster --task $taskarn --region "eu-west-1"
这篇关于如何将AWS CLI的输出保存在变量中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!