indirect shell-vars
Richard O'Keefe
ok at cs.mu.oz.au
Tue Sep 12 21:45:42 AEST 1989
In article <627 at targon.UUCP>, ruud at targon.UUCP (Ruud Harmsen) writes:
> I'm looking for a way to reference a variable in the Bourne-shell,
> whose name is given in another variable. ... Perhaps using "eval", but
> also executes the string, which is too much.
x="foo <baz> ugh"
y=x
Method 1:
eval 'z="${'$y'}"'
Method 2:
cmd="echo \"\${$y}\""
z=`eval $cmd`
They're not perfect, mind.
More information about the Comp.unix.questions
mailing list