查看匹配的行数:

grep -o “关键字xxxx” /etc/tomcat.log | wc – l

 

最近匹配的记录明细:

grep “关键字xxx” -A 1 /etc/tomcat.log | tail –n 10

 

查看其中一条前后10行:

grep -C 10 “具体行的唯一标示xxxx” /etc/tomcat.log