color grep

Every once in awhile I come across a feature of a piece of software, generally, a small utility that I hadn’t known about and that shows immediate value.  Today Jon showed me the --color flag for GNU grep.  It uses color to highlight the term you were searching for in the line returned.  For example:

# grep –color=auto -i metadata todo.txt
Metadata Functions to Move:
   MetadataView…Make sure only our indexed items are passed up.

Its a very simple thing, but one of those that I’m surpised I haven’t been using.  I know have a shell aliases for that.  See the grep documentation for more information.

[Update 6/2: linux.com has a great article on GNU grep’s new features which talks about the color.  One that I’m particularly expected about is the ability to use Perl-style regular expressions.]

3 thoughts on “color grep”

  1. Yeah, it looks like it wsa stuff added to gnu grep 2.5 (current version being a g0ff like 2.5.1.)  So, the BSDs miss out unless they are including gnu grep.  🙂

Leave a Reply