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
Tell me more
×
Unix & Linux Stack Exchange is a question and answer site for
users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.
|
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:
|
|||
|
|
grep (GNU grep) 2.9(Gentoo) – Michael Mrozek♦ Aug 20 '11 at 22:07GREP_*environment variable set? – Gilles Aug 21 '11 at 0:13