shell脚本中IF语句中的OR条件
我试图在shell脚本(Bash/Solaris)中的“if”语句中使用“or”条件。 我在下面尝试,但它给出了语法错误 我犯了什么错误shell脚本中IF语句中的OR条件,shell,if-statement,syntax-error,Shell,If Statement,Syntax Error,我试图在shell脚本(Bash/Solaris)中的“if”语句中使用“or”条件。 我在下面尝试,但它给出了语法错误 我犯了什么错误 if [ grep "$logtime" $blogs | grep "Authentication Failed" ] -o [ grep "$logtime" $slogs | egrep "AAA Authentication Failure|AAA Authorization Failure" ] > dptest 2>&1;the
if [ grep "$logtime" $blogs | grep "Authentication Failed" ] -o [ grep "$logtime" $slogs | egrep "AAA Authentication Failure|AAA Authorization Failure" ] > dptest 2>&1;then
set of commands.
fi
问候,,
Rahul不要将命令放入
[…]
中;这用于测试表达式
if ( grep "$logtime" $blogs | grep "Authentication failed" || grep "$logtime" $slogs | egrep "AAA Authentication Failure|AAA Authorization Failure" ) > dptest 2>&1
then
# commands
fi
我的答案中的括号不是if
语法的一部分,它们用于对命令进行分组,以便将所有输出重定向到dptest