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
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
This should work:
echo $(tmpvar=x$i && echo ${!tmpvar})
Example:
i=1
declare x$i=help
echo "$(tmpvar=x$i && echo ${!tmpvar})"
Output:
help