Color in grep output to distinquish the matching entries

2010-02-04 1 min read Linux

Most of the times I end up spending a lot of time to look for the string in the grep output when I do a search. This is quite frustrating and thus I looked at the options for grep command that would make my life easier and there definately is something. Here it is:

export GREP_COLOR=”5;36”

But for this to work you would still need to give the ”–color=auto” option in the grep command. There are two ways to do this, create a alias for grep as ”grep –color=auto” or specify the same in GREPOPTIONS.

Another option that is quite useful is ”-n” in conjuntion with ”-f”, which will show the line numbers also along with the filename.

comments powered by Disqus