grep and anchoring
Matthew Seaman
matthew at FreeBSD.org
Sun Jun 26 15:31:43 UTC 2016
On 26/06/2016 15:44, Daniël de Kok wrote:
> Note the anchoring (^), the pattern should only match any four characters at the beginning of the line, so the expected output is ‘1234’ and nothing more. ‘ 123' and '4 12' are not at the beginning of the line and should consequently not be printed to stdout.
>
> For comparison, the output of a recent GNU grep:
>
> —
> % echo "1234 1234 1234" | grep -o '^....'
> 1234
> —
You are completely correct -- this is a bug in grep(1) on FreeBSD. In
all current releases including the upcoming 11.0-RELEASE grep is
actually GNU grep version 2.1.5. However, the same bug occurs in
bsdgrep(1):
% echo 1234 1234 1234 | bsdgrep -o '^....'
1234
123
4 12
There is already an open PR about a very similar issue:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=201650
Could you update that PR with your findings? Especially that bsdgrep(1)
also shows the same problem.
Cheers,
Matthew
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 931 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20160626/3e7864bf/attachment.sig>
More information about the freebsd-questions
mailing list