Страница 1 из 1

Помогите с проверкой

Добавлено: 2011-02-17 18:40:25
Cancer

Код: Выделить всё

if [ ${curr_gw} = ${gw1} или ${curr_gw} = ${gw2} -a ${gw1_curr_status} -eq 0 -a ${gw2_curr_status} -eq 0 -a ${gw3_curr_status} -eq 1 ]
или так

Код: Выделить всё

if [ ${curr_gw} = ${gw1} или ${gw2} -a ${gw1_curr_status} -eq 0 -a ${gw2_curr_status} -eq 0 -a ${gw3_curr_status} -eq 1 ]
Как тут добавить "или" ?
|| не получается, пишет

Код: Выделить всё

[: missing ]
192.168.254.1: not found
[: missing ]
192.168.254.1: not found

Re: Помогите с проверкой

Добавлено: 2011-02-18 10:49:29
skeletor
Вместо '||' используй '-o'

Re: Помогите с проверкой

Добавлено: 2011-02-18 12:36:49
Cancer
Спасибо!

Код: Выделить всё

//> man test

Код: Выделить всё

     These primaries can be combined with the following operators:

     ! expression  True if expression is false.

     expression1 -a expression2
                   True if both expression1 and expression2 are true.

     expression1 -o expression2
                   True if either expression1 or expression2 are true.

     (expression)  True if expression is true.

     The -a operator has higher precedence than the -o operator.

     Some shells may provide a builtin test command which is similar or iden-
     tical to this utility.  Consult the builtin(1) manual page.

Re: Помогите с проверкой

Добавлено: 2011-02-18 12:51:23
kpp
Логичнее запись

Код: Выделить всё

 if [ выражение1 ] || [ выражение2 ] 
then
:
fi
ИМХО