Let's consider 2 variables in bash as following:
X = 8
Y = X
If I want to print the value of X
using the variable Y
I could do echo ${!Y}
and the value 8
will be printed
Now the question is, how can I change the value of X
using the variable Y
?
By using eval
:
$ X=8
$ Y=X
$ echo ${!Y}
8
$ eval $Y=3
$ echo $X
3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With