Prevent grep from removing the color

View: New views
1 Messages — Rating Filter:   Alert me  

Prevent grep from removing the color

by yangzhang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, I'm interested in cascading a bunch of coloring greps to
syntax-highlight lines.  E.g. given the string:

   user3 changed from Online to Offline

I'd like to be able to issue something like:

   GREP_COLORS='...white...' grep user3  |
   GREP_COLORS='...green...' grep Online |
   GREP_COLORS='...red.....' grep Offline

so that I see (in my made-up markup language):

   <white>user3</white> changed from <green>Online</green> to
<red>Offline</red>

However, it appears that grep always resets the coloring on the
non-matching portions of the line.  Is there any way around this?  Is
there a more suitable tool (perhaps some general-purpose syntax
highlighting tool)?  Thanks in advance for any help!
--
Yang Zhang
http://www.mit.edu/~y_z/


LightInTheBox - Buy quality products at wholesale price!