If I do
echo foo bar baz | grep -o -w baz the output is
foo bar baz (and an extra newline).
The expected output would be
baz as the -o option should only display the matched part.
I'm using Mac OS X 10.7.1 and the grep version is
grep (GNU grep) 2.5.1
There's a workaround by using the
If you insist on using
Seems like a bug to me. If you don't mind using the
2.5.1 seems is far from the latest release, but I suppose you could try filling a bug with Apple.
Alternatively you could get install the latest GNU grep via homebrew e.g.
The do the following: