7 ms·
The article addresses this: > The -F for grep indicates that we are only matching on fixed strings and not doing any fancy regex, and can offer a small speedup
by simpleigh 12y ago
The article addresses this:
> The -F for grep indicates that we are only matching on fixed strings and not doing any fancy regex, and can offer a small speedup, which I did not notice in my testing.
I guess grep is probably clever enough to choose a faster matching algorithm once it's parsed the pattern and discovered it doesn't contain any regex fun.
- clarkm 12y agoIn general grep seems smart enough that it would do that, but it hasn't been my experience. Just last week I was searching through a couple hundred gigs small xml files. I found that: $ LC_ALL=C fgrep -r STRING . was much faster than plain grep. This was on a CentOS 5 box, so maybe newer versions of grep are smarter. But then again, if I was on a newer box I'd just install and use ack or ag.
- paralelogram 12y agoLC_ALL=C makes grep faster because text matching is normally locale-sensitive, for example 'S' ('\x53' in Big5) is not a substring of '兄' ('\xA5\x53' in Big5).