``egrep (GNU grep) 2.5.1-FreeBSD'' will not correctly see the closing parenthesis of a grouping if it is not on the same line as the opening parenthesis. ``egrep (GNU grep) 2.4d'' did not have this problem. How-To-Repeat: echo hi | egrep '( hi)'
Hi (delayed response), This is actually intended behavior. It's not so much that it doesn't correctly see it, it's that newlines are pattern delimiters, so this is actually broken into two different patterns: '(', and 'hi)'. To verify, check: $ printf "hi\nthere" | egrep -o "hi er" hi er # Correct This is probably dual purpose: 1. Maintains consistency with file-read patterns (-f) 2. grep is inherently line-oriented, thus making it nonsensical to actually match on newlines.
Good point. I agree that it probably shouldn't be classified as a bug. I don't even remember what exactly led me to discover the problem in some script that I had, other than the obvious thing that I upgraded. The most remarkable thing to me was the difference between versions, that what had previously been accepted was now returning an error. I see little reason not to close this, so I will. (I'm unclear on what the difference between Working as Intended and Not a Bug are though, so apologies if I picked wrongly.)
(In reply to David C Lawrence from comment #2) > (I'm unclear on what the difference between > Working as Intended and Not a Bug are though, so apologies if I picked > wrongly.) Maybe we need a "Works as Written" resolution. :)