Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!agate!shelby!portia!forel!karish From: karish@forel.stanford.edu (Chuck Karish) Newsgroups: comp.unix.questions Subject: Re: indirect shell-vars Message-ID: <5265@portia.Stanford.EDU> Date: 12 Sep 89 21:18:24 GMT References: <627@targon.UUCP> Sender: USENET News System Reply-To: karish@forel.stanford.edu (Chuck Karish) Organization: Mindcraft, Inc. Lines: 18 In article <627@targon.UUCP> ruud@targon.UUCP (Ruud Harmsen) wrote: >I'm looking for a way to reference a variable in the Bourne-shell, >whose name is given in another variable. I found the following solution >using a sub-shell myself, but it seems rather clumsy:. >export x1; x1=one >export x2; x2=two >echo which var\? >read xx >sh -c "echo \$x`echo $xx`" eval echo \$x$xx By escaping some of the `$' signs, you can cause eval to expand the variables in the desired order. Chuck Karish karish@mindcraft.com (415) 493-9000 karish@forel.stanford.edu