How can I search for a multiline pattern in a file?
Here is the example using GNU grep
:
grep -Pzo '_name.*\n.*_description'
-z
/--null-data
Treat the input as a set of lines, each terminated by a zero byte (the ASCII NUL character) instead of a newline.
Which has the effect of treating the whole file as one large line.
See -z
description on grep's manual and also common question no 14 on grep's manual usage page
Why don't you go for awk:
awk '/Start pattern/,/End pattern/' filename