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


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
5 views
Features:
my_param="123" param="my_param"


How do I get the value of the variable $my_param using $param?
by | 5 views

3 Answers

0 like 0 dislike
# eval a=\\$$param
# echo $a
123
by
0 like 0 dislike
C version bash 2, you can use the notation ${!variable}
\r$ echo ${!param}
123
by
0 like 0 dislike
Something like
\r
my_param="123" param=`echo $my_param` 
by

Related questions

0 like 0 dislike
1 answer
asked Mar 24, 2019 by KriegeR
0 like 0 dislike
2 answers
0 like 0 dislike
6 answers
asked Mar 23, 2019 by gnusy
0 like 0 dislike
7 answers
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
27,967 users