Combine two variables

March 31, 2011 at 10:10:56
Specs: AIX
Using ksh, can I use one variable to form part of another i.e.


echo $FS($MYVAR)

... i want this to display "itworks"

See More: Combine two variables

Report •

March 31, 2011 at 10:23:24

# create a shell variable
eval FS$MYVAR=\$FS2
echo $FS2 # should display: itworks

Report •

March 31, 2011 at 10:30:33
thanks nails... still struggling though i'm afraid (new to ksh etc!)

My value for MYVAR is going to be changing and i'll have a lot of stored variables eg

FS1 = one
FS2 = two
FS3 = three

so i want to be able to substitute MYVAR in place of the number and simply print/echo the result.

Does that makes sense?

Report •

March 31, 2011 at 10:34:25
Sorry, my bad. This should do it:

eval echo \"\$FS$MYVAR\"

Report •
Related Solutions

Ask Question