Original question: "Catch an entire function with grep" on Stack Overflow
It is possible to use (GNU) grep to do multiline matching[^fn1], but you're
probably making more work for yourself that way, because sed can do basically
everything grep can plus make replacements.
Using grep -zoP to do multiline matching is fundamentally the same trick as
what's proposed below: turning your file into one long string, separated by