grep -A 100 -B 100 ‘要查找的字符‘ 被查的文件file
-A after 后面
-B before 前面
grep -n ‘要查找的字符串‘ 被查的文件file 返回行数 例如: 123456:要查找的字符串 再使用: sed -n ‘1,10p‘ 被查的文件file 查看文件的1-10行
grep -C 5 ‘要查的字符串‘ 被查的文件file 显示file文件里匹配字串那行以及上下5行
原文:https://www.cnblogs.com/xuebing26/p/11555084.html