On Tue, 16 Nov 2010, Mike Miller wrote:

> On Tue, 16 Nov 2010, Mike Miller wrote:
>
>> Thanks for the tip.  I had tried "grep -f", but it was slower.  I 
>> didn't know about "grep -F", but I just tried it and it also is slower:
>> 
>> time echo -e "A\nB" | grep -F - data_file | grep -E "(A|B).*(A|B)"
>> 
>> real    2m44.955s
>> user    2m51.399s
>> sys     0m2.174s
>
>
> A guy on another list came up with the best overall solution so far. 
> It isn't quite as fast as my tricky "tee"-based method:
>
> time fgrep -e A -e B data_file | grep -E '(A|B).*(A|B)'
>
> real    0m6.411s
> user    0m6.205s
> sys     0m0.621s


To be fair to Justin Krejci:  He recommended grep -F, but it was my idea 
to use it in the way I did, which did not work well, but fgrep is the same 
as grep -F, so this is identical to the fgrep line above:

time grep -F -e A -e B data_file | grep -E '(A|B).*(A|B)'

In other words, Justin's idea was quite sound.  I used to think that fgrep 
was grep -f, but it is grep -F.  I've learned a lot about grep in the past 
few hours!

Mike