egrep -o '^..' Doesn't Match Start of Line Correctly.
Bug #210890 reported by
Ralph Corderoy
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 '..')
$
To post a comment you must log in.
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