Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.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
Parsing 查看日志文件的最后15行,检查是否有“错误”;“错误”;重复3次并执行命令_Parsing_Unix_Text_Logfile - Fatal编程技术网

Parsing 查看日志文件的最后15行,检查是否有“错误”;“错误”;重复3次并执行命令

Parsing 查看日志文件的最后15行,检查是否有“错误”;“错误”;重复3次并执行命令,parsing,unix,text,logfile,Parsing,Unix,Text,Logfile,我想要一个脚本,可以读取文本文件的最后15行,如果单词“error”出现3次以上,它将执行一个命令。#/bin/bash #!/bin/bash if [ `tail -15 <file> | grep error | wc -l` -gt 3 ] then echo "Too many errors..." else echo "Everything is fine." fi 如果[`tail-15 | grep error | wc-l`-gt 3] 然后 回显“错

我想要一个脚本,可以读取文本文件的最后15行,如果单词“error”出现3次以上,它将执行一个命令。

#/bin/bash
#!/bin/bash
if [ `tail -15 <file> | grep error | wc -l` -gt 3 ]
then
   echo "Too many errors..."
else
   echo "Everything is fine."
fi
如果[`tail-15 | grep error | wc-l`-gt 3] 然后 回显“错误太多…” 其他的 echo“一切都很好。” fi
或在命令行上:

if [ `tail -15 <file> | grep error | wc -l` -gt 3 ]; then echo "Too many errors..."; else echo "Everything is fine."; fi
if[`tail-15 | grep error | wc-l`-gt 3];然后回应“错误太多…”;否则就呼应“一切都很好”;fi

到目前为止,您尝试了什么?