We can set RE_NO_SUB for calling regex only to check syntax. It brings performance gains in cases to have a lot of enormous epsilon nodes. $ printf '(%020000d)\n' | sed 's/0/|/g' >pat (before) $ time -p env LC_ALL=C src/grep -Ef pat /dev/null real 6.15 user 4.62 sys 1.52 (after) $ time -p env LC_ALL=C src/grep -Ef pat /dev/null real 0.66 user 0.19 sys 0.46