Skip to main content
and the ${!var} is the name of the variable , instead of the "value"
Source Link
glenn jackman
  • 88.5k
  • 16
  • 124
  • 179

In bash v4 you can use a "nameref"

$ foobar_darwin_amd64=pinto
$ package=foobar
$ declare -n var=${package}_darwin_amd64
$ echo $var"$var"
pinto
# and

The variable name you constructed can be obtained with the indirect variable expansion syntax:

$ .....
echo $"${!var}"
foobar_darwin_amd64

In bash v4 you can use a "nameref"

$ foobar_darwin_amd64=pinto
$ package=foobar
$ declare -n var=${package}_darwin_amd64
$ echo $var
pinto
# and .....
echo ${!var}
foobar_darwin_amd64

In bash v4 you can use a "nameref"

$ foobar_darwin_amd64=pinto
$ package=foobar
$ declare -n var=${package}_darwin_amd64
$ echo "$var"
pinto

The variable name you constructed can be obtained with the indirect variable expansion syntax:

$ echo "${!var}"
foobar_darwin_amd64
and the ${!var} is the name of the variable , instead of the "value"
Source Link

In bash v4 you can use a "nameref"

$ foobar_darwin_amd64=pinto
$ package=foobar
$ declare -n var=${package}_darwin_amd64
$ echo $var
pinto
# and .....
echo ${!var}
foobar_darwin_amd64

In bash v4 you can use a "nameref"

$ foobar_darwin_amd64=pinto
$ package=foobar
$ declare -n var=${package}_darwin_amd64
$ echo $var
pinto

In bash v4 you can use a "nameref"

$ foobar_darwin_amd64=pinto
$ package=foobar
$ declare -n var=${package}_darwin_amd64
$ echo $var
pinto
# and .....
echo ${!var}
foobar_darwin_amd64
Source Link
glenn jackman
  • 88.5k
  • 16
  • 124
  • 179

In bash v4 you can use a "nameref"

$ foobar_darwin_amd64=pinto
$ package=foobar
$ declare -n var=${package}_darwin_amd64
$ echo $var
pinto