grep命令在每次匹配后添加结束行 [英] grep command to add end line after every match
本文介绍了grep命令在每次匹配后添加结束行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您是否有任何想法如何添加一些终结线如
do you have any idea how to add some end line like
"=========================================================================================="
$每场比赛后b
$ b
after every match
tail -f error.log -n 2000 | grep -B 10 -A 25 'Exception:'
这个命令会打印所有异常日志,但我喜欢请参阅每个异常日志的一个分隔符行。
this command prints all Exceptions log but i likes to see one seperator line for each exception log.
推荐答案
您需要以下选项:
You want the following option:
- group-separator = SEP
使用SEP作为组分隔符。默认情况下,SEP是双连字符( - )。
--group-separator=SEP
Use SEP as a group separator. By default SEP is double hyphen (--).
演示: b
$ 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
这篇关于grep命令在每次匹配后添加结束行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文