That is searching for a multi-line pattern, which the usual grep
does not appear to support. There are alternative tools, e.g.,
However, GNU grep is said to support this as well:
to use a newline in a pattern. The options used however include the "experimental" -P
which may make it less suitable than pcregrep
:
-P, --perl-regexp
Interpret PATTERN as a Perl regular expression. This is highly
experimental and grep -P may warn of unimplemented features.
-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. Like the
-Z or --null option, this option can be used with commands like
sort -z to process arbitrary file names.
-o, --only-matching
Print only the matched (non-empty) parts of a matching line,
with each such part on a separate output line.
Some experimental options are useful, others less so. This one was noted as the source of problems in Searching for non-ascii characters.