简体   繁体   English

将 helm 命令的 output 存储在一个变量中

[英]Store output of helm command in a variable

I am trying to store the output of my helm command in a variable in bash script and trying to echo it but it return giving an error..syntax error in expression我正在尝试将我的 helm 命令的 output 存储在 bash 脚本中的一个变量中并尝试回显它但它返回给出错误..表达式中的语法错误

Here is my code MY_VAR=$((helm ls -A -o json)) echo ${MY_VAR}这是我的代码 MY_VAR=$((helm ls -A -o json)) echo ${MY_VAR}

To execute one command after another you must add && between them.要一个接一个地执行命令,您必须在它们之间添加&& Also, you do not need double parentheses.此外,您不需要双括号。

For example:例如:

MY_VAR=$(helm ls -A -o json) && echo ${MY_VAR}

Its because you got double brackets这是因为你有双括号
Change into变成

 MY_VAR=$(helm ls -A -o json)

this solve the problem for me这为我解决了问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM