Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

grep -f maximum number of patterns?

Tags:

grep

unix

I'd like to use grep on a text file with -f to match a long list (10,000) of patterns. Turns out that grep doesn't like this (who, knew?). After a day, it didn't produce anything. Smaller lists work almost instantaneously.

I was thinking I might split my long list up and do it a few times. Any idea what a good maximum length for the pattern list might be?

Also, I'm rather new with unix. Alternative approaches are welcome. The list of patterns, or search terms, are in a plaintext file, one per line.

Thank you everyone for your guidance.

like image 920
Chris J. Vargo Avatar asked Jan 20 '13 19:01

Chris J. Vargo


1 Answers

From comments, it appears that the patterns you are matching are fixed strings. If that is the case, you should definitely use -F. That will increase the speed of the matching considerably. (Using 479,000 strings to match on an input file with 3 lines using -F takes under 1.5 seconds on a moderately powered machine. Not using -F, that same machine is not yet finished after several minutes.)

like image 128
William Pursell Avatar answered Nov 29 '22 14:11

William Pursell