Why is 'grep -i' so slow? How to do it faster for ASCII?
- by Vi.
Consider:
$ time lzop -d < tvtropes-index.lzo | egrep -B 5 '[Dd][eE][sS][cC][eE][nN][dD] ?[Ff][rR][oO][mM]'
real 0m0.438s
$ time lzop -d < tvtropes-index.lzo | egrep -B 5 'descend ?from' -i
real 0m11.294s
Both search case insensitively. Why is the -i version so slow? How do I make grep -i fast without entering things like [iI][nN] [tT][hH][iI][sS] [wW][aA][Yy]?
For example,
perl -ne 'print if /descend ?from/i'
works fast, but '-B 5' is not as trivial to implement as in grep (as well as other options).