1)动态查询文件某个关键字的内容
tail -f 文件名 |grep -a ‘关键字’
2)动态查询文件,并高亮显示
tail -f catalina.out | perl -pe ‘s/(DEBUG)/\e[1;34m$1\e[0m/g’
3)查看关键字并显示颜色
grep -C10 --color -a ‘关键字’ error.log
同:cat error.log | grep ‘关键字’ -a --color -C5
-C10:表示显示关键字的前后10行,-A前10行,-B后10行
–color:显示验证
-a:解决Binary file error.log matches的问题
4)过滤屏蔽关键字
tail -f app.log | grep -v ‘DEBUG’