GNU bug report logs -
#37754
wish for grep --and -eX -eY -eZ (X∩Y∩Z intersection, not X∪Y∪Z union)
Previous Next
Full log
Message #14 received at 37754 <at> debbugs.gnu.org (full text, mbox):
Paul Eggert wrote:
> 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.
Not for me personally, because I almost always want to use it with -Fwi :-)
(-F is a lot faster - about as fast as LC_COLLATE - and it also means
I don't have to think about escaping special characters.)
> [...]
>
> 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.
I hadn't thought about -o, and I agree that is not very obvious.
Given an input file like
30$ Gamdias EROS (M2) USB Multi-Color Lighting Gaming Headset
30$ Gamdias POSEIDON E1 Gaming Combo 3-in-1 K/B+3200dpi Optical Mouse+Stereo Headset
30$ GeIL (GP34GB1600C11SC) 4GB DDR3 1600 Desktop RAM
30$ GeIL Pristine (GP44GB2400C17SC) 4GB Single DDR4 2400 Desktop RAM
30$ GeIL SO-DIMM 4GB (GGS34GB1600C11SC) 1.35V (Low Voltage) 4GB DDR3 1600 Notebook Ram
Where currently "grep -Fw -e 4GB -e DDR4 -o" prints
4GB
4GB
DDR4
4GB
4GB
I would expect "grep -Fw -e 4GB -e DDR4 --and" to print the same thing as
grep -Fw 4GB | grep -Fw DDR4 | grep -Fw -e 4GB -e DDR4 -o
i.e.
4GB
DDR4
This bug report was last modified 2 years and 186 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.