Replacing line breaks with nulls first is an option. That’s a lot of extra processing for very large blocks of text though.
Using regular grep is possible with the right flags, or you could also use pcre2grep with the -M flag, which should be available on every distro nowadays. See this Stack Overflow article for details.
pcregrep is not automatically installed with Debian but it’s in the official repos. It seems common to get:
pcregrep: Too many errors - abandoned.
pcregrep:Error -8, -21or -27 means that a resource limit was exceeded.
pcregrep: Check your regex for nested unlimited loops.
But it will help in many cases. I can see that it works on sufficiently small files. I noticed the built-in grep function for emacs can be modified to use pcregrep w/-M added instead of grep, which I find quite important because emacs makes it very easy to jump around to visit different results. In the end it’s still a hack.
Replacing line breaks with nulls first is an option. That’s a lot of extra processing for very large blocks of text though.
Using regular grep is possible with the right flags, or you could also use
pcre2grepwith the-Mflag, which should be available on every distro nowadays. See this Stack Overflow article for details.pcregrepis not automatically installed with Debian but it’s in the official repos. It seems common to get:pcregrep: Too many errors - abandoned. pcregrep: Error -8, -21 or -27 means that a resource limit was exceeded. pcregrep: Check your regex for nested unlimited loops.But it will help in many cases. I can see that it works on sufficiently small files. I noticed the built-in grep function for emacs can be modified to use pcregrep w/-M added instead of grep, which I find quite important because emacs makes it very easy to jump around to visit different results. In the end it’s still a hack.