linux常用命令合集

日志

关键字查询

查询文件名为test.log 关键字为debug的日志
cat -n test.log |grep “debug”
linux常用命令合集

行号查询

查询名为test.log的日志从92行开始,往后20行的数据
cat -n test.log |tail -n +92|head -n 20

查看ERROR日志

查询test.log中ERROR级别的日志
cat -n test.log |grep “ERROR”
注意error要大写,如果小写的话可能搜到别的打印出的日志
linux常用命令合集

查看关键日志并分页

查询test.log中92行后,往后500行的日志,并分页查看
cat -n test.log |tail -n +92|head -n 500|less
linux常用命令合集

参考文档

Linux之vim详解

linux查看日志的几种方法

常用Linux日志查看命令