Linux 查看日志的常用命令
1.查询最近多少条日志:
tail -n 100 default.log
2.根据关键字查询日志:
cat -n default.log |grep 'error'
3.根据关键字查出后多少行的日志
tail -n 100 file.log | grep "关键字"
4.根据关键字查出后100行中包含关键字的行和该行的前10行
tail -n 100 file.log | grep "关键字" -B10
5.根据时间段查询日志:
sed -n '/2022-03-18 10:12/,/2022-03-18 12:15/p' xxx.log