How to change the value of second level variable in Bash? How to change the value of second level variable in Bash? bash bash

How to change the value of second level variable in Bash?


By using eval:

$ X=8$ Y=X$ echo ${!Y}8$ eval $Y=3$ echo $X3


This might work for you:

X=8; Y=X; echo ${!Y}8echo $(($Y=3))3echo $X3(($Y=7)); echo $X7

Here's a couple more ways:

let $Y=4; echo $X4_[$Y=6]=1; echo $X6