Csh question

Michael Greim greim at sbsvax.UUCP
Mon Jul 25 22:00:10 AEST 1988


In article <8807191241.AA18881 at decwrl.dec.com>, ellis at ultra.dec.com (David Ellis) writes:
< In the csh, the expression $name or ${name} looks up the variable with the
< given name and substitutes its value.
< 
< 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`"
< 
< ----
< David Ellis
Yes. Here it is:
	eval echo \$$x

Works in all csh's I could get my hands on quickly.

	-mg
-- 
+------------------------------------------------------------------------------+
| UUCP:  ...!uunet!unido!sbsvax!greim   | Michael T. Greim                     |
|        or greim at sbsvax.UUCP           | Universitaet des Saarlandes          |
| CSNET: greim%sbsvax.uucp at Germany.CSnet| FB 10 - Informatik (Dept. of CS)     |
| ARPA:  greim%sbsvax.uucp at uunet.UU.NET | Bau 36, Im Stadtwald 15              |
| Phone: +49 681 302 2434               | D-6600 Saarbruecken 11, West Germany |
+------------------------------------------------------------------------------+
| # include <disclaimers/std.h>                                                |
+------------------------------------------------------------------------------+



More information about the Comp.unix.questions mailing list