ksh : how do I de-reference a variable using another variable
am 10.01.2008 15:53:04 von terry433iid
say I have :-
x=3
and I want to use this variable to access the third positional
parameter of a script ($3) then the following won't work :-
echo $x
as that will give me the integer value "3" ... but I want the value of
$3 which is something completely different..
what is ksh syntax here please???
e.g.
# bar=x
#x=foo
# echo $bar
x
# echo $`echo $bar`
$x
how can I get *value* of $x
Re: ksh : how do I de-reference a variable using another variable
am 10.01.2008 16:04:45 von Janis Papanagnou
On 10 Jan., 15:53, "terry433...@yahoo.com"
wrote:
> say I have :-
> =A0 =A0 =A0 x=3D3
> and I want to use this variable to access the third positional
> parameter of a script ($3) then the following won't work :-
> =A0 =A0 =A0echo $x
> as that will give me the integer value "3" ... but I want the value of
> $3 which is something completely different..
>
> what is ksh syntax here please???
eval echo \${$x}
Janis
> e.g.
>
> # bar=3Dx
> #x=3Dfoo
> # echo $bar
> x
> # echo $`echo $bar`
> $x
>
> how can I get *value* of $x