1

I have some large text file(3 GB rails log file) on a centos os with a corrupted byte in this text file. When trying to search some pattern using grep, it runs indefinitely and I have to close it, however with pcregrep it takes less than a minute, so any clue why this difference ?

My search using grep:

grep -Pzo "2016-04-20(.*?)SomeController#index" production.log | wc -l

using pcregrep:

pcregrep -M "2016-04-20(.*?)SomeController#index" production.log | wc -l
  • The algorithm used in `pcregrep` could be more faster for this specific pattern. It may skip more bytes than the algorithm used in `grep` in the case of a mis-match. – jofel Apr 23 '16 at 08:23
  • 3
    Your are using different pattern with `grep` and `pcregrep`. For true comparison, use the same pattern. – jofel Apr 23 '16 at 08:25

0 Answers0