Store output of helm command in a variable

Viewed 82

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

Here is my code MY_VAR=$((helm ls -A -o json)) echo ${MY_VAR}

2 Answers

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

Related