我有一个简单的if循环,它在一台服务器上运行但在另一台服务器上运行。我可以在myscript.log日志文件中找到这个词。
#!/bin/ksh
./myscript.sh install $2 $3 $4
sleep 5
if grep -q SUCCESSFUL myscript.log
then
echo "Install is good"
else
echo "Error occured during Install"
fi
输出:
if: Expression Syntax.
Grep在剧本之外:
mymachine:~>grep SUCCESSFUL myscript.log
Install is SUCCESSFUL
答案 0 :(得分:2)
错误:
if:表达式语法
表示您使用的shell不是Bourne shell的变体。
编写条件语句的另一种方法是:
grep -q SUCCESSFUL myscript.log && echo "Install is good" || echo "Error occured during Install"
(而不是if
... fi
循环。)