前言:有些项目没有集成日志系统,为了更加方便的查找日志,整理了些日志查询命令
#查看最近1000行日志
tail -n 1000 //start.log
#根据关键词搜索日志
grep -C 20 "Exception" //start.log
#最近的10个错误,加上错误后的10行
tac //start.log | grep -B10 -n -m10 ERROR | tac
tac //start.log | grep -B10 -m10 -E 'Exception|ERROR' | tac
#查看最近1000行日志中的错误日志
tail -n 10000 //start.log | grep -A10 -E 'Exception|ERROR'
#搜索文件中含有“resines”字符串
find . -name "*.text" | xargs grep resines
#搜索文件名中含有的resines
find . -name "*.text" | grep resines