grep/egrep fails with $ anchor?

The $ seems to fail for me. I'm using GNU grep 2.5.4 (that is, nothing out of the ordinary, just what came with my distro) but I can't get the final anchor $ to work for me. (^ works as usual.)

Behavior without anchor:

$ /bin/grep -E 'tium' file
tritium
tertium quid

Expected behavior:

$ /bin/grep -E 'tium$' file
tritium

Actual behavior:

$ /bin/grep -E 'tium$' file

That is, it finds no results. Any ideas?

Using -e to specify the expression doesn't help. Similarly, using double or no quotes gives the same result.

Could there be non-printables or spaces following the ium?

Try piping the output of the first grep to od -c

1 Like

Oh, that's it -- it was formatted with Windows CR/LF. Thanks!