Skip site navigation (1)Skip section navigation (2)
Date:      12 Aug 2010 14:06:04 -0400
From:      "John R. Levine" <johnl@iecc.com>
To:        freebsd-questions@FreeBSD.ORG, jacks@sage-american.com
Subject:   Re: Grepping a list of words
Message-ID:  <alpine.BSF.2.00.1008121400390.42946@joyce.lan>
In-Reply-To: <201008121644.o7CGiflh099466@lurza.secnetix.de>
References:  <201008121644.o7CGiflh099466@lurza.secnetix.de>

next in thread | previous in thread | raw e-mail | index | archive | help
> > Gee, 50 words, that's about a 300 character pattern, that's not a problem
> > for any shell or version of grep I know.
> >
> > But reading the words from a file is equivalent and as you note most
> > likely easier to do.
>
> The question is what is more efficient.  This might be
> important if that kind of grep command is run very often
> by a script, or if it's run on very large files.

It's exactly the same, since it's the same program using the same search 
algorithm.  The only thing that's different is the input language for the 
pattern.  What looks like a bunch of separate patterns in the input file 
is internally turned into one pattern that is then compiled into a state 
machine that it uses to match the input.

R's,
John



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.00.1008121400390.42946>