johnl@iecc.cambridge.ma.us (John R. Levine) (11/27/90)
In article <1990Nov27.003659.3521@informix.com> you write: >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? No more confusing than any other Bourne shell string munging. The trick is to build up the assignment string and then use eval to rescan it: # Prints: # Iteration is first_time # Iteration is second_time 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 Regards, John Levine, johnl@iecc.cambridge.ma.us, {spdcc|ima|world}!iecc!johnl