[comp.unix.shell] Evaluating a nexted variable

mcneild@mcneild.Software.Mitel.COM (Doug McNeil) (11/11/90)

Hello,

A friend needed to get the value of a variable which was contained in
a variable:

$a=b
$c=a

Determing the value of "a" given "c".

I came up with:

$eval z="$`echo $c`"
$echo $z

Not being a shell guru, I expect there are lots of better ways to do
this. Any comments?

--
----------------------------------------------------------------------------->
"Smokin" Doug McNeil			| ...!uunet!mitel!spock!mcneild
Mitel Corporation, Kanata, Ontario	| (613)592-2122
"I know a lot of fancy dancers.." - Cat Stevens	|

pfalstad@spot.Princeton.EDU (Paul John Falstad) (11/11/90)

In article <MCNEILD.90Nov10134417@mcneild.Software.Mitel.COM> mcneild@mcneild.Software.Mitel.COM (Doug McNeil) writes:
>$ a=b
>$ c=a
>Determing the value of "a" given "c".
>I came up with:
>$ eval z="$`echo $c`"
>$ echo $z

Or:

$ eval z=\$$c
$ echo $z

or:

$ eval echo \$$c


--
Paul Falstad, pfalstad@phoenix.princeton.edu PLink:HYPNOS GEnie:P.FALSTAD
"Your attention, please.  Would anyone who knows where the white courtesy
phone is located please pick up the white courtesy phone."

cpcahil@virtech.uucp (Conor P. Cahill) (11/11/90)

In article <MCNEILD.90Nov10134417@mcneild.Software.Mitel.COM> mcneild@mcneild.Software.Mitel.COM (Doug McNeil) writes:
>$eval z="$`echo $c`"

eval z=\$$c

will do what you want.

-- 
Conor P. Cahill            (703)430-9247        Virtual Technologies, Inc.,
uunet!virtech!cpcahil                           46030 Manekin Plaza, Suite 160
                                                Sterling, VA 22170