Color in grep output to distinquish the matching entries
2010-02-04
118 words
1 min read
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.
Related Articles:
- 2010/02/04 Color output from ls – based on file type
- 2010/01/25 grep -v with multiple patterns.
- 2009/11/16 bash colors
Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.