How do I get grep color in the file names before each match?

Posted by chimerical on Super User See other posts from Super User or by chimerical
Published on 2011-03-16T21:05:50Z Indexed on 2011/03/17 0:12 UTC
Read the original article Hit count: 412

Filed under:
|
|

If I run grep -ir "somethingtomatch" . from the current directory, I typically get results like this:

./some/path/file1.html: filecontent filecontent keyword filecontent
./some/path/file2.html: filecontent filecontent filecontent keyword
./some/path/file3.html: filecontent keyword filecontent filecontent
./some/path/file4.html: keyword filecontent filecontent filecontent

I used grep --color=auto -ir 'somethingtomatch" . but it only highlights the keywords in white on a red highlight. I'm trying to get file names on the left color-coded too. How do I do that?

I'm using Terminal.app in OS X with bash and xterm (and I tried xterm-color too).

© Super User or respective owner

Related posts about unix

Related posts about colors