I am referencing variables in the following way
var1="greeting"
greeting="Welcome!"
How do I echo var1 in such a way that it outputs Welcome! ?
I am referencing variables in the following way
var1="greeting"
greeting="Welcome!"
How do I echo var1 in such a way that it outputs Welcome! ?
$ eval echo \$$var1
Welcome!
use single quotes
$ var1="greeting"
$ greeting='Welcome!'
$ echo ${!var1}
Welcome!
Note that the example by Frans only works in the Bash shell.