grep three extra lines code example
Example 1: grep lines between two patterns in unix
$ sed -n '/aaa/,/cdn/p' file
aaa
b12
cdn
$ sed -n '/zdk/,/dke/p' file
zdk
aaa
b12
cdn
dke
Example 2: grep show lines between matches
Just use following structure to get result between two different patterns:
sed -n '/^pattern1/,/^pattern2/p;/^pattern2/q' file.txt