Subtitute Variable inside Variable in Bash
Example below is using Bash for variable variables subtitution.
$ hello="Hello World"
$ foobar="hello"
$ echo "${!foobar}"
Hello World
Subtitute Variable inside Variable using eval
This is for other shell which do not recognize "${!}" syntax. It utilise eval so use it with caution.
$ hello="Hello World"
$ foobar="hello"
$ eval echo "\$${foobar}"
Hello World
0 comments:
Post a Comment