On Tue, 16 Nov 2010, Justin Krejci wrote:

> If and when your patterns are string literals (no special meta 
> characters) you might shave a bit more by doing "grep -F".

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

That's worse than just doing the grep -E and skipping the grep -F.  I find 
it surprising that I can run "grep A" followed by "grep B" many times 
faster than "echo -e 'A\nB' | grep -F -".  The "grep -F" method is so slow 
that it seems like some kind of error in the programming.  I mean it's 
taking more than 20 times as long!  That really shouldn't happen.

But seriously, thanks anyway because it was a very good idea.

Mike