Subject: bug#37754: wish for grep --and -eX -eY -eZ (X∩Y∩Z intersection, not X∪Y∪Z union)

From: Paul Eggert <[email-masked]>
Date: Wed, 16 Oct 2019 11:57:31 -0700

Wouldn't it be more useful to have an intersection operator in regular 
expressions? That is, the pattern 'A\&B' would match anything that is 
matched by both A and B. If A and B have parenthesized subexpressions, 
both sets of parentheses would match and would count.

Assuming concatenation has higher precedence than \&, the requested 
behavior could be achieved via:

   grep '.*X.*\&.*Y.*\&.*Z.*'

This approach would allow intersection to be nested inside other 
operations. Also, it would clarify how other features work. For example, 
grep -o has clear semantics with this approach, whereas the semantics of 
grep -o are not so clear with the proposed --and option.