echo, eval, etc

echo, eval, etc

Post by Peter Samuels » Sun, 07 Jun 1998 04:00:00




Quote:> A (very) easy way to do it, by typing the following :

> $ var1=1
> $ var2=2
> $ var3=3
> $ for i in 1 2 3
> > do
> >     print - "var${i} = ${var}${i}"
> > done

BZZZZT.  Thank you for playing.  This only works if var{k} == {k} for
all k, like your example.  The real answer was already given: use an
eval, something like

  eval echo var$i = \$var$i

--
Peter Samuelson
<sampo.creighton.edu ! psamuels>