2

I have the following case:

A=1
echo $A # output 1
B='A'
echo $B  # output A
echo "\$$B=2" # output $A=2
echo "\$$B=2" | eval # this won't set $A to 2

I'd like $A to get 2 as value.

darioguarascio
  • 1,077
  • 11
  • 15

1 Answers1

0

Found a solution using declare ( Dynamic variable names in Bash )

B='A'
declare "$B=2"
echo $A # output 2
darioguarascio
  • 1,077
  • 11
  • 15