Reputation: 132192
I know that bash supports indirect variable references using the !
operator:
$ ABC=123
$ DEF=ABC
$ echo ${!DEF}
123
and that's nice. But - it doesn't seem work when I want to set the value of a variable, whose name I get from another variable:
$ ABC=123
$ DEF=ABC
$ !DEF=1234
-bash: !DEF=1234: event not found
$ ${!DEF}=1234
-bash: 123=1234: command not found
Other than by using eval
- how can I set the value of a variable whose name is the value of another variable?
Upvotes: 0
Views: 114