Grep output with multiple Colors?

You can cascade greps with different colors by specifying –color=always and using the regular expression ‘foo|$’ to pass all lines.

For example:

tail -f myfwlog | GREP_COLOR='01;36' egrep --color=always 'ssh|$' | GREP_COLOR='01;31' egrep -i --color=always 'drop|deny|$'

If you want the entire line to be highlighted, update your regular expression accordingly:

.... GREP_COLOR='01;31' egrep -i --color=always '^.*drop.*$|^.*deny.*$|$'

Leave a Comment