0

How can I echo the value of $globevar?

globevar="testing something"

somefunc() {
 echo $1 #will echo exactly whats passed
 echo ${$1} # errors out
}

somefunc globevar # globevar

somefunc globevar # -bash: ${$1}: bad substitution

Khorem
  • 61
  • 5
  • 1
    Are you looking for indirect expansion, as in [this answer](https://stackoverflow.com/questions/16553089/dynamic-variable-names-in-bash/18124325#18124325)? – Gordon Davisson Apr 20 '20 at 00:23
  • Does this answer your question? [Dynamic variable names in Bash](https://stackoverflow.com/questions/16553089/dynamic-variable-names-in-bash) – Socowi Apr 20 '20 at 09:39

0 Answers0