命令行查看日志

tail -f test.log 实时监控日志
tail -100f test.log 实时监控100行日志
tail -n 10 test.log 查看最后10行日志
tail -n +10 test.log 查看文件中行号10后边的日志


head -n 10 test.log 查看前10行日志
head -n -10 test.log 查看文件中行号10前边的日志


查找日志

1.查询关键字相关日志
cat -n test.log | grep 关键字

2.比如上边查出来后,要看2274行附近日志。根据上边的行号(2274),(tail -n +2274)查询行号2274后的日志,( head -n 20)然后再从结果中查前50条
cat -n test.log | tail -n +2274 | head -n 50

 

posted @ 2024-05-07 16:00  新手娃娃菜  阅读(17)  评论(0编辑  收藏  举报