Linux查询日志命令

如:test.log日志文件

查询最后10行日志
tail -n 10 test.log

查询日志前10条
head -n 10 test.log

条件查询
cat -n test.log | grep "条件关键字"

查询关键字后100行数据(假设有500行)
(表示从第400行开始,往后查询200行数据)
cat -n test.log | tail -n +400 | head -n 200

动态监控
tail -f test.log

动态监控最后20行
tail -f -n 20 test.log

原文地址:https://www.cnblogs.com/wangfan9/p/13571888.html