grep command to add end line after every match

grep, linux, shell, unix

Solution

You want the following option:

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

Demo:

$ 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

Problem

do you have any idea how to add some end line like ``` "==========================================================================================" ``` 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.

Original source

Related problems