$ echo foobar | grep -o '^.'
f
o
o
b
a
r
There is a beginning-of-line anchor '^' so grep should only match 'f',
not the rest.
$ grep --version
grep (GNU grep) 2.5.1
A few other test cases:
$ echo foobar | grep -o '^[fb]' # this one works properly
f
$ echo foobar | grep -o '^[fb]..' # this one is broken
foo
bar
$ echo foobar | grep -o '^[fb].' # but this works properly!
fo
I (being a black box sort of tester) am going to guess that, after
matching the pattern, grep -o *deletes* the beginning of the string, or
moves the pointer, or something ... so that grep -o can continue doing
its magic ... but then it is able to match at the beginning of the
string again.
End-of-line anchors seem to work properly.
~David.