启动.sh脚本,会读取日志文件第一行,然后进行判断,现在需要读取日志文件里面的最后一行信息然后判断,对脚本了解一点点,请问一下各位该如何实现啊 ,我想用tail -n -1 log/server.log去直接获取最后一行的信息,但是如何赋值判断呢
start()
{ whlie ture
do
test -s $logFile
if test $? -eq 0
then
echo "the fiile log/server.log" is address"
cat $logFile | while read line
do
echo "the line is [$line]"
test "$line" = "started"
if test $? -eq 0
then
echo " $[NAME]" successfully!"
exit 0
else
echo "$[NAME] Fail!"
exit 0
fi
done
break
else
slepp 2
continue
fi
done
}
以前的代码是这样