This is in a Linux environment, in case that matters.

pi.txt is a text file listing the first billion digits of pi, all in one line (no line breaks, no spaces.)

Right now to find the character position of an arbitrary sequence, e.g. 334455, I'm doing this:

LANG=C grep -aob '334455' pi.txt | head -1

It's pretty darn slow, and I think I've optimized grep as much as possible in this case. Consumes a CPU at 100% and takes about 15 seconds.

What's a better solution?