Tuesday, March 10, 2009
Like bash ls command, grep supports color in its output. i.e. you can highlight the text that grep matches with color.
This is controlled by "--color" option with grep command which basically surround the matching string with the marker find in GREP_COLOR environment variable.
$ grep --color=auto <pattern> <file>
Grep's default highlight color is red (shown below in the snap).
You can change this color by setting the GREP_COLOR environment variable to different combinations (from the color code list given below).
$ export GREP_COLOR='1;30;43'
which basically highlights the matched pattern with foreground color black and background color yellow (shown below in the snap).
The set display attributes list:
0 Reset all attributes
- Bash ls command color support
- Colorful man pages in ubuntu
© Jadu Saikia http://unstableme.blogspot.com