How to echo a dynamic variable’s content in shell script ?
i=1 declare x$i=help echo $(echo x$i) echo $x$i
Current output:
x1 1
Desired output:
help
Advertisement
Answer
Use eval:
i=1 declare x$i=help eval "echo $x$i"
How to echo a dynamic variable’s content in shell script ?
i=1 declare x$i=help echo $(echo x$i) echo $x$i
Current output:
x1 1
Desired output:
help
Use eval:
i=1 declare x$i=help eval "echo $x$i"