Sun*_*Sun 7 unix linux shell grep
你知道如何添加一些结束线吗?
"=========================================================================================="
Run Code Online (Sandbox Code Playgroud)
每场比赛后
tail -f error.log -n 2000 | grep -B 10 -A 25 'Exception:'
Run Code Online (Sandbox Code Playgroud)
此命令打印所有异常日志,但我喜欢看到每个异常日志的一个分隔符行.
Chr*_*our 21
您需要以下选项:
--group-separator = SEP
使用SEP作为组分隔符.默认情况下,SEP为双连字符( - ).
演示:
$ 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
Run Code Online (Sandbox Code Playgroud)