加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – grep命令在每次匹配后添加结束行

发布时间:2020-12-13 16:57:06 所属栏目:Linux 来源:网络整理
导读:参见英文答案 Add blank line after every result in grep5个 你知道如何添加一些结束线吗? "==========================================================================================" 每场比赛结束后 tail -f error.log -n 2000 | grep -B 10 -A 25
参见英文答案 > Add blank line after every result in grep5个
你知道如何添加一些结束线吗?
"=========================================================================================="

每场比赛结束后

tail -f error.log -n 2000 | grep -B 10 -A 25 'Exception:'

此命令打印所有异常日志,但我喜欢看到每个异常日志的一个分隔符行.

解决方法

您需要以下选项:

–group-separator=SEP
Use SEP as a group separator. By default SEP is double hyphen (–).

演示:

$cat file
before
exception 1
after
foo
bar
before
exception 2
after

$grep -A 1 -B 1 --group-separator======================== exception file 
before
exception 1
after
=======================
before
exception 2
after

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读