How can I escape a string literal easily for use as a regex with grep?
e.g.,
Say I wanted to implement a procmail killfile, that might, say contain a
mail subject line (dropped in with a mutt macro) like this:
Re: OT: Politics [Was:Social Contract]
(Hypothetical situation, of course...)
Then
David Purton wrote:
How can I escape a string literal easily for use as a regex with grep?
e.g.,
Say I wanted to implement a procmail killfile, that might, say contain a
mail subject line (dropped in with a mutt macro) like this:
Re: OT: Politics [Was:Social Contract]
(Hypothetical
On Tue, May 02, 2006 at 03:01:02AM -0400, Roberto C. Sanchez wrote:
David Purton wrote:
How can I escape a string literal easily for use as a regex with grep?
e.g.,
Say I wanted to implement a procmail killfile, that might, say contain a
mail subject line (dropped in with a mutt
At 1146586566 past the epoch, David Purton wrote:
How can I escape a string literal easily for use as a regex with grep?
If you feed it through perl, you can enclose the suspect string with \Q
and \E. Here's an excerpt from a perl script which I generate my
procmail recipes with:
$reexp
David Purton wrote:
I need something automatic though. I have no control on what formail
returns. It just returns the subject as a string. I need to be able to
search for that string in the killfile just using literals and not
caring about regex.
Can you not just use grep -F? To use your
On Tue, May 02, 2006 at 11:09:30AM +0100, Jon Dowland wrote:
At 1146586566 past the epoch, David Purton wrote:
How can I escape a string literal easily for use as a regex with grep?
If you feed it through perl, you can enclose the suspect string with \Q
and \E. Here's an excerpt from a perl
On Wed, May 03, 2006 at 09:34:19AM +0930, David Purton wrote:
snip
I ended up using fgrep, which if I had read the grep manual I would have
found does what I want (Blush).
This works well:
# subject kill file
SUBJECT=`formail -zxSubject:`
:0:
* ? fgrep -qx $SUBJECT
On Tue, May 02, 2006 at 05:22:34PM -0700, Christopher Nelson wrote:
On Wed, May 03, 2006 at 09:34:19AM +0930, David Purton wrote:
snip
I ended up using fgrep, which if I had read the grep manual I would have
found does what I want (Blush).
This works well:
# subject kill file
8 matches
Mail list logo