Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!uwm.edu!mixcom!rrvvrr From: rrvvrr@mixcom.UUCP (Bill Suetholz) Newsgroups: comp.unix.internals Subject: Re: puzzle Message-ID: <45@mixcom.UUCP> Date: 30 Nov 90 00:32:47 GMT References: <1990Nov27.003659.3521@informix.com> Reply-To: rrvvrr@mixcom.UUCP (Bill Suetholz) Distribution: usa Organization: MIX: Milwaukee Information eXchange (Public access Usenet, Email) Lines: 29 I tried this shell script and it performs as requested... -----------------------------CUT HERE ------------------------------------- #!/bin/sh first_time="first_time" second_time="second_time" PREFIX="first second" SUFFIX="time" for WORDS in $PREFIX do eval ITERATION=\$${WORDS}_${SUFFIX} echo "Iteration is $ITERATION" done exit 0 ---------------------------------------------------------------------------- A few things to note: 1) the line with the eval was supposed to have WORDS not PREFIX in it. 2) use eval to get shell to evaluate the line twice; once for $WORDS and $SUFFIX and once for $first_time or $second_time. Bill Suetholz (bills@mixcom.UUNET)