Grep and BzGrep with Wildcard in Search Pattern

Hello All,

I hope this is the right area. If not, Kindly let me know and I will report in the appropriate spot.

I am needing to find a search pattern that will make the * act as Wildcard in the search pattern instead of being literal.

The example I am using is bzgrep "to=<*@domain.com>" mail.0.bz2

In the above example the * is being literal when I need it to be a wildcard. I need to search for any emails that went to the domain(omitting any entries where email went out as the domain).

Thank you!

The equivalent of DOS or glob style '*' (that any any number) is:

.*

That's "dot" (any char) "asterisk" (zero or more times)

Asterisk by itself is previous pattern 0 or more times, where in your case the pattern is just the character "less than".

Please, try:

 bzgrep 'to=<.*@domain\.com>' mail.0.bz2

Perhaps a better pattern for you might be:

grep 'to=<[^@][^@]*@[^>][^>]*>'

... or hard code the domain part as you have done, but escape the "dot" as Aia mentioned.

Thank you, All these worked. I also found that I needed to do a "| grep -v " at the end because it was also getting entries from "orig_to=<".

Thank you all for the support and quick responses!

or maybe it supports some form of word boundary like:

bzgrep '\<to=<.*@domain\.com>' mail.0.bz2

or:

bzgrep '\bto=<.*@domain\.com>' mail.0.bz2