Re: bash
On Tue, Mar 11, 2003 at 01:26:20PM +0200, Konstantin Kubatkin wrote:
>
> в PHP есть возможность взять имя переменной из значения другой переменной,
> т.е.:
>
> <?php
> $a = "hello";
> $$a = "world";
> echo "$a ${$a}";
> //produces the exact same output as:
> echo "$a $hello";
> ?>
>
> есть ли такое в bash? мне надо сделать вот так:
>
> for i in 1 2 3 4 5 6 7 8 9 10 ; do
> if [ -n "$IF_IP_${i}" ] ; then < вот тут надо проверять значение
> переменных ${IF_IP_1}, ${IF_IP_2}, etc
> NUM=`expr ${i} + 1`
> fi
> done
В bash как и во всех скриптовых языках есть eval.
if [ -n `eval echo \\$IF_IP_${i}` ] ; then
--
Best regards,
-Vlad
Reply to:
- References:
- bash
- From: Konstantin Kubatkin <debian@3logic.net>