Csh question

Mike Bennett mbennett at midas.UUCP
Tue Jul 26 06:19:28 AEST 1988


in article <8807191241.AA18881 at decwrl.dec.com>, ellis at ultra.dec.com (David Ellis) says:
> 
> Is there any way to get the value of a variable whose name is the value of
> another variable?
> 
> e.g. if we've done set x=a and set a=3, is there any simple csh expression
> in terms of x that yields the value of a (3)?
> 
> Csh gives an error message "Variable syntax." if I try something like
> 	echo ${$x}
> or even
> 	echo "`echo {\$}$x`"
> 

Try "eval echo \$$x". Eval is a built-in csh (and sh) command which
effectively causes the command line to be scanned twice - once by the
shell when arguments are passed to eval, and then by the command passed
to eval (that's why the first $ is escaped). hope this helps.

Mike Bennett
Languages Development
Gould Computer Systems Division, Ft. Lauderdale, Florida
.....!{uunet,sun,pur-ee,brl-smoke}!gould!mbennett
I am paid to work and to think for my employer - so I do.
I am NOT paid to speak for my employer - so I don't.



More information about the Comp.unix.questions mailing list