From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041020 Description of problem: Grep does not recognise beginning of a line when using the "matching part" switches. If the line really matches the given pattern, then grep tries to match the pattern in the line with the last match deleted (try the following line: $ echo aa | grep -o ^a Expected result is a while grep gives a a which is a bug. Similarly, $ echo ab | grep -o ^. should return a but returns a b Version-Release number of selected component (if applicable): grep-2.5.1-31.2 How reproducible: Always Steps to Reproduce: 1. Run grep -c or grep -o. Use the special character ^ in the regular expression. 2. If there is a matching line that contains the pattern more than once with no other characters between the matches, all the matches are written out. Additional info:
This happens with pristine 2.5.1a as well.
Reported upstream: https://savannah.gnu.org/bugs/index.php?func=detailitem&item_id=11579