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 regards, Jonas -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org