Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!voder!pyramid!ctnews!risky!pase60!gilles From: gilles@pase60.Convergent.Com (Gilles Courcoux) Newsgroups: comp.unix.wizards Subject: Re: nested loops Summary: eval(1) command usage Message-ID: <511@risky.Convergent.COM> Date: 10 Aug 90 16:15:51 GMT References: <4103@herbie.misemi> Sender: root@risky.Convergent.COM Reply-To: gilles@pase60.UUCP (Gilles Courcoux) Distribution: na Organization: Unisys Network Computing Group (CT), San Jose, CA Lines: 36 In article <4103@herbie.misemi> you wrote: >The problem lies in the $`echo $i` statment Right, double variable expansion like that is resolved through the use of the eval(1) command as in : eval echo '$'$i When the shell read the command, it expands it into eval echo $them # the first time ! and then eval(1) do his job : evaluating its arguments, including variables expansion and then execute the command which is by now : echo one two three The echo(1) command is needed because eval(1) then exec(2)utes its first argument. Your script become : this="one two three" that="four five six seven" them="eight nine ten" all="this that them" # for i in $all do for j in `eval echo '$'$i` do echo $i $j done done Have a nice day, Gilles Courcoux E-mail: sun!pyramid!ctnews!pase60!gilles Unisys Network Computing Group Phone: (408) 435-7692