[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#37754: wish for grep --and -eX -eY -eZ (X∩Y∩Z intersection, not X∪Y∪
From: |
Trent W. Buck |
Subject: |
bug#37754: wish for grep --and -eX -eY -eZ (X∩Y∩Z intersection, not X∪Y∪Z union) |
Date: |
Thu, 17 Oct 2019 11:19:54 +1100 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
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
- bug#37754: wish for grep --and -eX -eY -eZ (X∩Y∩Z intersection, not X∪Y∪Z union), Trent W. Buck, 2019/10/14
- bug#37754: wish for grep --and -eX -eY -eZ (X∩Y∩Z intersection, not X∪Y∪Z union), Norihiro Tanaka, 2019/10/16
- bug#37754: wish for grep --and -eX -eY -eZ (X∩Y∩Z intersection, not X∪Y∪Z union), Paul Eggert, 2019/10/16
- bug#37754: wish for grep --and -eX -eY -eZ (X∩Y∩Z intersection, not X∪Y∪Z union),
Trent W. Buck <=
- bug#37754: wish for grep --and -eX -eY -eZ (X∩Y∩Z intersection, not X∪Y∪Z union), Paul Eggert, 2019/10/17
- bug#37754: wish for grep --and -eX -eY -eZ (X∩Y∩Z intersection, not X∪Y∪Z union), Trent W. Buck, 2019/10/18
- bug#37754: wish for grep --and -eX -eY -eZ (X∩Y∩Z intersection, not X∪Y∪Z union), Paul Eggert, 2019/10/18
- bug#37754: wish for grep --and -eX -eY -eZ (X∩Y∩Z intersection, not X∪Y∪Z union), Paul Jackson, 2019/10/18
bug#37754: wish for grep --and -eX -eY -eZ (X∩Y∩Z intersection, not X∪Y∪Z union), Norihiro Tanaka, 2019/10/19