Currently, I use
egrep --color 'error|$'
to highlight every word in a line containing the word error:
I would like to highlight the entire line though so that the entire string appears in red.
How can I achieve that?
Currently, I use
egrep --color 'error|$'
to highlight every word in a line containing the word error:
I would like to highlight the entire line though so that the entire string appears in red.
How can I achieve that?
To highlight the complete line, you should expand the regex so that it includes all (if any) characters before and after the desired term. Do this by prepending and appending .*
to the term being searched for:
echo "foo bar error baz" | egrep --color '.*error.*|$'
|$
in the regex while testing. I've fixed that now.
– Anthony Geoghegan
Dec 15 '16 at 15:33
grep -E --color '.*error.*|^'
– Costas Dec 15 '16 at 12:30