Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!uflorida!novavax!midas!mbennett From: mbennett@midas.UUCP (Mike Bennett) Newsgroups: comp.unix.questions Subject: Re: Csh question Message-ID: <1265@midas.UUCP> Date: 25 Jul 88 20:19:28 GMT References: <8807191241.AA18881@decwrl.dec.com> Organization: Gould CSD, Fort Lauderdale, FL Lines: 24 in article <8807191241.AA18881@decwrl.dec.com>, ellis@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.