nested loops
Randal Schwartz
merlyn at iwarp.intel.com
Fri Aug 10 17:23:59 AEST 1990
In article <7318 at helios.TAMU.EDU>, skdutta at cs (Saumen K Dutta) writes:
| this="one two three"
| that="four five six seven"
| them="eight nine ten"
| all="this that them"
| #
| for i in $all
| do
| k='eval echo $`echo $i`'
| for j in `eval $k`
| do
| echo $i $j
| done
| done
Waaaaayyyy too many eval's and echo's. Try this:
#!/bin/sh
this="one two three"
that="four five six seven"
them="eight nine ten"
all="this that them"
for i in $all
do
eval 'for j in $'$i'
do
echo $i $j
done'
done
And look, I didn't mention Perl once (oops!).
(But why is this in wizards? Sigh.)
--
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III |
| merlyn at iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/
More information about the Comp.unix.wizards
mailing list