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?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityTo 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.
Dec 15, 2016 at 15:33
grep -E --color '.*error.*|^'