S
S
Stamm2011-01-17 03:08:40
PowerShell
Stamm, 2011-01-17 03:08:40

Bash: how to get the value of a variable if its name is in another variable

Available:

my_param="123"
param="my_param"


How can I get the value of the $my_param variable via $param?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
C
cuprum, 2011-01-17
@Stamm

# eval a=\$$param
# echo $a
123

O
osdyng, 2011-01-17
@osdyng

From bash 2, you can use the ${!variable} notation
$ echo ${!param}
123

A
Alexey Skobkin, 2011-01-19
@skobkin

Something like


my_param="123"
param=`echo $my_param`

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question