tail -f logfile.log | perl -pe 's/.*foo*/\e[1;41m$&\e[0m/g'
will color all the lines containing the pattern "foo" in the logfile.log file.
How can I make use of this in order to highlight not the whole line but just the exact pattern?
echo "WARN ERROR foo"|sed 's#WARN#\x1b[33m&#; s#ERROR#\x1b[31m&#; s#foo#\x1b[32m&#'
I mean if I want to do something like this, how can I manage?