Results 1 to 2 of 2
x=1
c1=string1
c2=string2
c3=string3
echo c$x
c1
I'd like to have the output be string1 by entering something like:
echo $(c$x)
can someone point me in the right direction....
- 04-14-2010 #1Just Joined!
- Join Date
- Feb 2005
- Posts
- 14
bash variable inside variable
x=1
c1=string1
c2=string2
c3=string3
echo c$x
c1
I'd like to have the output be string1 by entering something like:
echo $(c$x)
can someone point me in the right direction.
- 04-14-2010 #2Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
Use eval, something like:
Code:x=1 c1=string1 eval "var=\$c${x}" echo $var


Reply With Quote