Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
shell脚本中IF语句中的OR条件_Shell_If Statement_Syntax Error - Fatal编程技术网

shell脚本中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

我试图在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;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