Hi Jonas,

Jonas Helgi Palsson <[EMAIL PROTECTED]> wrote: 
> Hi
> 
> On Tuesday 08 January 2008 14:00:38 Sebastian Reitenbach wrote:
> > Hi,
> >
> > I want to substitue some variable names, to build another variable,
> > therefore I have a script like this:
> >
> > #!/bin/bash
> > NETS="NET0 NET1 NET2"
> > NET0_IF=eth0
> > NET1_IF=eth1
> > NET2_IF=eth2
> >
> > CNT=0
> > for NET in $NETS;do
> >   echo ${${NET}_IF}
> > done
> >
> > What I want is the output to look like like:
> > eth0
> > eth1
> > eth2
> >
> > but whatever I try, it ends with a "bad substitution", or wrong output.
> >
> > Is there a way of this kind of double substitution in bash?
> >
> 
> Use "eval"
> 
> 
> #!/bin/bash
> NETS="NET0 NET1 NET2"
> NET0_IF=eth0
> NET1_IF=eth1
> NET2_IF=eth2
> 
> CNT=0
> for NET in $NETS;do
>     eval echo \$${NET}_IF
> done

thanks a lot for your fast answer, this is exactly what I was looking for.


sebastian

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to