grep fails when using both --ignore-case and --only-match options. Example:
$ echo "abc" | grep -io abc
abc
$ echo "ABC" | grep -io abc
$
But
$ echo "abc" | grep -i abc
abc
$ echo "ABC" | grep -i abc
ABC
According to man page:
-o, --only-matching Show only the part of a matching line that matches PATTERN. -i, --ignore-case Ignore case distinctions in both the PATTERN and the input files.
Is it a bug of grep or I didn't get the map page?
I am using Mac OS X 10.6.8 and
$ grep --version
grep (GNU grep) 2.5.1
Found this link: http://lists.gnu.org/archive/html/bug-gnu-utils/2003-11/msg00040.html
Of course it is possible to use workaround like grep -o [aA][bB][cC]
, but this doesn't seem to be a good option.