Add “–color” to your command
grep –color localhost /etc/hosts
127.0.0.1 loopback localhost # loopback (lo0) name/address
The string “localhost” will appear in RED.
1. You need GNU ‘grep’ for this to work
2. Don’t use “GREP_OPTIONS” environment variable in your shell startup scripts to accomplish this. It can break several scripts.
More information can be found in this link: http://www.gnu.org/software/grep/manual/grep.html#Environment-Variables