Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!apple!agate!eos!data.nas.nasa.gov!gigantor!hahn From: hahn@nas.nasa.gov (Jonathan Hahn) Newsgroups: comp.unix.internals Subject: Re: puzzle Message-ID: <1990Nov27.024517.2207@nas.nasa.gov> Date: 27 Nov 90 02:45:17 GMT References: <1990Nov27.003659.3521@informix.com> Sender: news@nas.nasa.gov Distribution: usa Organization: NAS Program, NASA Ames Research Center, Moffett Field, CA Lines: 29 In article <1990Nov27.003659.3521@informix.com> housed@infmx.informix.com (Darryl House) writes: >The following is a Bourne shell script that illustrates >what I am trying to do: set a shell variable that >contains the contents of another one that is referred >to by concatenating two others. Sufficiently confusing? The following script creates a string which accomplishes the assignment to ITERATION, and calls "eval" to evaluate the string. BTW, the echo needs double quotes so the value of ITERATION will be printed. ---------------------------------------------------------------------- firsttime="first_time" secondtime="second_time" PREFIX_WORDS="first second" SUFFIX="time" for PREFIX in $PREFIX_WORDS do eval 'ITERATION=$'$PREFIX$SUFFIX echo "Iteration is $ITERATION" done ---------------------------------------------------------------------- -jonathan hahn -- hahn@gigantor.nas.nasa.gov wk: (415) 604-4360 ..!ames!amelia!hahn hm: (408) 736-7014