grep and anchoring

Daniël de Kok me at danieldk.eu
Sun Jun 26 13:11:06 UTC 2016


Dear all,

After a BSD hiatus of many years, I am tinkering with FreeBSD again. I’ve run into some strange issue with grep and beginning of line (^) anchoring:

—
% echo "1234 1234 1234" | egrep -o '^….'
1234
 123
4 12
% echo "123412341234" | egrep -o '^....'
1234
1234
1234
—

Any idea what is going on here?

(Recent GNU grep from ports gives the expected output.)

With kind regards,
Daniël de Kok

Ps., grep on OS X, which seems to be the same version has similar problems…


More information about the freebsd-questions mailing list