egrep -o '^..' Doesn't Match Start of Line Correctly.

Bug #210890 reported by Ralph Corderoy
4
Affects Status Importance Assigned to Milestone
grep
Unknown
Unknown
grep (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: grep

Ubuntu 7.10. Package grep 2.5.1.ds2-6build1.

Consider

    $ echo 0123456789 | egrep -o '^..'
    01
    23
    45
    67
    89
    $

The -o option: "Show only the part of a matching line that matches PATTERN." Hence I'd expect the output to be a single line containing "01". But it seems the circumflex is being ignored. The output is the same with the circumflex as without it.

    $ cmp <(echo 0123456789 | egrep -o '^..') <(echo 0123456789 | egrep -o '..')
    $

Revision history for this message
Koen (koen-beek) wrote :

Confirmed

this also happens with grep (egrep calls grep but simply add the -E option)

end of line ($) seems to works correctly (even on file with multiple line):

$ echo 0123456789 | grep -o '..$'
89
$

it looks to me like, grep, once it has matched with something, simply starts the "new line" where the previous match ended
I'm not sure whether this is a correctly working feature or a bug but I think it certainly is counterintuitive

I'm using "grep 2.5.1.ds2-6build1" on ubuntu amd64 gutsy (7.10)

   Koen

Changed in grep:
status: New → Confirmed
Revision history for this message
Ralph Corderoy (ralph-inputplus) wrote :

The GNU grep folks know about this problem. It's their

    https://savannah.gnu.org/bugs/?11579

Based on this Changelog entry,

    http://cvs.savannah.gnu.org/viewvc/grep/ChangeLog?root=grep&r1=1.279&r2=1.280

it appears they've fixed it already. Revision 1.280 of Changelog was released in their v2_5_2, according to the CVS tag on revision 1.292 of Changelog.

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

Fixed in Intrepid. Please see https://wiki.ubuntu.com/StableReleaseUpdates if you would like to pursue
a fix in stable releases.

Thanks for your help.

Changed in grep:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.