<<< Date Index >>>     <<< Thread Index >>>

[OT] GNU Grep (was: Re: hook for not editing email)



On Fri, Jan 02, 2004 at 02:41:21PM +0100, Magnus Bäck wrote:
> On Friday, January 02, 2004 at 05:28 CET,
>      David Yitzchak Cohen <lists+mutt_users@xxxxxxxxxxxxxx> wrote:

> > I ilke this version of muttedit better, actually:
> > #!/bin/sh
> > 
> > file=$1
> > if egrep "^Subject:" $file | egrep -q "<eom>\$" ; then
> >  touch $file
> > else
> >  vi $file
> > fi
> 
> Is there a reason not to use
> 
>    if egrep -q '^Subject: .*<eom>$' $file ; then

Well, if you're stupid (like myself), there is.  If you're smart enough to
notice my extra step, there's no reason not to combine them into one ;-)

> Am I missing some subtle point? The -q option seems to be specific to
> GNU grep, by the way.

Yeah, here's a more portable way to do it:
if egrep -q '^Subject: .*<eom>$' $file >/dev/null 2>&1 ; then

 - Dave

-- 
Uncle Cosmo, why do they call this a word processor?
It's simple, Skyler.  You've seen what food processors do to food, right?

Please visit this link:
http://rotter.net/israel

Attachment: pgpbnj7JUekel.pgp
Description: PGP signature