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!
cjcox
November 10, 2015, 11:17am
2
Pages for logged out editors learn more
A regular expression (shortened as regex or regexp; sometimes referred to as rational expression) is a sequence of characters that specifies a search pattern in text. Usually such patterns are used by string-searching algorithms for "find" or "find and replace" operations on strings, or for input validation. Regular expression techniques are developed in theoretical computer science and formal language theory.
The concept of regular expressions b...
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".
Aia
November 10, 2015, 11:19am
3
Please, try:
bzgrep 'to=<.*@domain\.com>' mail.0.bz2
cjcox
November 10, 2015, 11:22am
4
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!
Aia
November 10, 2015, 11:43am
6
mancountry:
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