Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!mitel!herbie!adley From: adley@herbie.misemi ( iccad) Newsgroups: comp.unix.wizards Subject: nested loops Message-ID: <4103@herbie.misemi> Date: 9 Aug 90 19:17:28 GMT Distribution: na Organization: Mitel Corporation, Canada Lines: 43 Hi, We are trying to write a Bourne shell script that includes two nested loops as follows !# /bin/sh 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 $`echo $i` do echo $i $j done done we want (and expected!) the output: this one this two this three that four that five that six that seven them eight them nine them ten The problem lies in the $`echo $i` statment the `echo $i` preforms as expected and the result is one of this, that, or them the $ infront of this statment however is taken as a literal $ and does not return the value of the variable this or that or them instead it returns $this or $that or $them. Does anybody know why this happens or how we can get the results that would be expected here (with the exception of doing it in a C shell or in a C program). Thanks.