I have huge log files, and I am trying to "filter" them according to their line prefixes. Using grep
is really fast, but not fast enough; typical results:
$ time grep "E ::" app.log
real 0m11.159s
user 0m10.081s
sys 0m1.040s
I thought I might save grep
some effort if I'll tell it that the prefix E ::
is actually a prefix, that is, it appears in the beginning of the line. I believed that this will let grep skip looking for it along the long lines in my log file. However, as it seems, it doesn't do much:
$ time grep "^E ::" app.log
real 0m11.152s
user 0m10.229s
sys 0m0.884s
Grepping ^E
is about 15% faster.
Do you have any idea why? Can you think of a faster way to filter these 9GB log files according to the first char in each line?