- grep -C 5 foo file 显示file文件里匹配foo字串那行以及上下5行
- grep -B 5 foo file 显示foo及前5行
- grep -A 5 foo file 显示foo及后5行
- -------------------------------------------------------------------------------------------------
- grep结果太多, 可否只取前面10行匹配的结果
- grep ...... | head -10
- -------------------------------------------------------------------------------------------------
- 一、使用cat、tail、head组合
- 1、查看最后1000行的数据
- cat filename | tail -n 1000
- 2、查看1000到3000行的数据
- cat filename | head -n 3000 | tail -n +1000
- 1、cat filename 打印文件所有内容
- 2、tail -n 1000 打印文件最后1000行的数据
- 3、tail -n +1000 打印文件第1000行开始以后的内容
- 4、head -n 1000 打印前1000的内容
- 二、使用sed命令
- 显示1000到300行的数据
- sed -n '1000,3000p' filename
- https://blog.csdn.net/u011487593/article/details/52287991
- cat run.log.2018-06-01 |grep -C 10 '粤B7M61W'