Wednesday, August 08, 2012

highlight grep output with color

With --color=auto, grep will highlight the matching portion of the line in color when it outputs to a terminal, while avoiding the use of any potentially-harmful terminal control sequences when standard output goes somewhere else (like a file or pipe). If you like the colorful grep, you can simply export GREP_OPTIONS='--color=auto' in your shell startup script.

grep's default highlight uses a red color. You can change this color by setting the GREP_COLOR environment variable to a different escape sequence fragment. I use export GREP_COLOR='1;32', which produces a bright green.

Ref: http://www.debian-administration.org/articles/460 

No comments:

Post a Comment