grep -Fo may not match longest pattern in grep 2.26 or later including current master. $ printf 'abce\n' > in $ printf 'abcd\nc\nbce\n' > pat $ LC_ALL=C src/grep -Fof pat in c We expect "bce" in this case.