文章引用:
https://blog.csdn.net/xc_zhou/article/details/81119583
1、从第3000行开始,显示1000行。即显示3000~3999行
cat filename | tail -n +3000 | head -n 1000
2、显示1000行到3000行
cat filename| head -n 3000 | tail -n +1000
注意两种方法的顺序
分解:
tail -n 1000:显示最后1000行
tail -n +1000:从1000行开始显示,显示1000行以后的
head -n 1000:显示前面1000行
3、用sed命令
sed -n '5,10p' filename
这样你就可以只查看文件的第5行到第10行。
4、随文件变化显示文件末尾几行
tail -f filename
5、查看文件关键字前后几行
cat @bic.center.debug.log | grep -A 10 -B 10 'exception'
6、grep命令查看某个指定时间段的日志
grep '时间' '日志文件名 '
例如:我要查shop-bussiness.log.2018-11-06文件中2018年11月6号11:34至11点37之间的日志信息,可以这么做:
grep '2018-Nov-06 11:3[4-7]' shop-bussiness.log.2018-11-06