|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Hi everybody!
I need some help with this... I have those 3 variables defined on ksh: VAR=TONTO NUM=1 TONTO1=OK I'd like to obtain TONTO1's value but using VAR and NUM. If I do: echo ${VAR${NUM}} It returns (on HP UX): sh: ${VAR${NUM}}: The specified substitution is not valid for this command. |
|
#2
|
|||
|
|||
|
You will need to use eval but be aware that this leads to tricky syntax especially with complex commands.
eval echo \$${VAR}${NUM} This makes ksh parse the command twice. On the first pass the backslash stops ksh from trying to expand the following $, but the backslash is removed. Also on the first pass, ${VAR} and ${NUM} are expanded. On the second pass, it looks like: echo $TONTO1 |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > getting a ksh variable value |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|