Friday, June 21, 2013

How to highlight a searching text in "tail -f" output

When we are investigating an software issue of a software run on a unix machine, we normally use "tail -f" command to see the live log messages logged by the software (for e.g: checking managed server logs in a weblogic server). If you are looking the log for finding a specific log message, it will be easier if you can make the search word highlighted in some color in the output.

Following method is a one of way you can achieve that task. Please note that to write ^[ character, you should press Ctrl+V and then Ctrl+[

tail -f testEcho.txt | sed "s/\\(search\\)/^[[33;1m\\1^[[0m/g"



No comments: