Linux grep 命令查看符合条件文本的相近几行
来源:互联网 发布:特种加工3b编程实例 编辑:程序博客网 时间:2024/06/06 19:58
查日志时,grep 到自己想要的行之后,还想看下符合条件的附近日志记录
man grep 发现果然已经有这个参数
Context Line Control -A NUM, --after-context=NUM Print NUM lines of trailing context after matching lines. Places a line containing a group separator (--) between contiguous groups of matches. With the -o or --only-matching option, this has no effect and a warning is given. -B NUM, --before-context=NUM Print NUM lines of leading context before matching lines. Places a line containing a group separator (--) between contiguous groups of matches. With the -o or --only-matching option, this has no effect and a warning is given. -C NUM, -NUM, --context=NUM Print NUM lines of output context. Places a line containing a group separator (--) between contiguous groups of matches. With the -o or --only-matching option, this has no effect and a warning is given.
简单示例及解释如下:
grep -A 5 'parttern' inputfile //打印匹配行的后5行 grep -B 5 'parttern' inputfile //打印匹配行的前5行 grep -C 5 'parttern' inputfile //打印匹配行的前后5行
0 0
- Linux grep 命令查看符合条件文本的相近几行
- linux grep命令(查找文件里符合条件的字符串)
- grep在一个文本中查找符合条件的文本
- linux命令之---grep命令用于查找文件里符合条件的字符串
- linux利用grep查看打印匹配的下几行或前后几行的命令
- linux利用grep查看打印匹配的下几行或前后几行的命令
- linux利用grep查看打印匹配的下几行或前后几行的命令
- grep-查找符合条件的字符串
- linux grep命令,强大的文本搜索
- linux grep命令,强大的文本搜索
- linux grep命令,强大的文本搜索
- linux grep命令,强大的文本搜索
- linux 命令 文本查找 grep
- 【每日一句shell】grep匹配符合多个条件的行
- 用grep 查出符合多个条件的用法
- linux grep查看指定内容上下几行
- Linux--文本查看命令
- linux下的文本处理命令sed&awk&grep
- 时间显示的处理
- Ubuntu 14.04 挂载 3TB 大硬盘问题
- 在eclipse中加入DTD文件
- MVP 深引用方式的简单实现
- Oracle/mysql数据库默认端口
- Linux grep 命令查看符合条件文本的相近几行
- 也许你并不需要 Gulp, Grunt ?
- Spring MVC数据绑定大全
- python代理ip 贴吧相关 2016.03.01回顾
- Tomcat服务绑定域名
- javascript 中的货币格式化
- 在xcode5中修改整个项目名
- 合同比对
- redis常用配置