Highlight a single word *always* in a terminal

Using bash, you can highlight all the word 'FAIL' in red using the following commands:

txtred=$(echo -e '\e[0;31m')
txtrst=$(echo -e '\e[0m')
bash | sed -e "s/FAIL/${txtred}FAIL${txtrst}/g"

What it does is creating a new bash shell and editing stdout of this new shell using sed. If you want to end the stdout edition, simply type exit to return back to your previous shell. You can find more color commands here. The echo -e variation is needed to get the real ESCAPE value of \e.

I tried it with echo and cat in this subshell and it is working. However, it breaks programs expecting a terminal as their output like vi. I guess that it would also break programs using special output buffering. It is also breaking commands like echo -n FAIL and change the behavior of commands like ls (ls prints many files per line when the output is a terminal, and one file per line when the output is a pipe).


clide works fine. I use it on RHEL 6.2, from the EPEL repository