I am using grep
with -P
(Perl regular expression) to colorize strings:
echo aaa bbb ccc ddd eee | grep --color=always -P "^[^#]*\K(bbb|ccc)|^"
in the above example, I want to colorize the string bbb
and ccc
. However, grep only colorizes the last one (ccc
).
how can I modify my regular expression, so that both strings match and are colorized ?