ksh : how do I de-reference a variable using another variable

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
terry433iid [ Do, 10 Januar 2008 15:53 ] [ ID #1904185 ]

Re: ksh : how do I de-reference a variable using another variable

On 10 Jan., 15:53, "terry433... [at] yahoo.com" <terry433... [at] 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
Janis Papanagnou [ Do, 10 Januar 2008 16:04 ] [ ID #1904186 ]
Linux » comp.unix.shell » ksh : how do I de-reference a variable using another variable

Vorheriges Thema: plotting from the shell
Nächstes Thema: Urgent req for Unix Shell Script Developer