Basically, I have a file whose lines I want to color with different colors if it matches 1 of 2 regular expressions with grep. If regexp1 is matched, then use one color; if regexp2 is matched, use another.
However, grep colors with one color at a time, so what I'd like to do is pipe the output of grep into another grep statement witch a different color.
However, grep color is controlled with an environment variable GREP_COLOR (this is deprecated in favour of GREP_COLORS, but didn't get that working on windows so I'm using GREP_COLOR instead)
So the batch file will look something like this:
@echo off setlocal set GREP_COLOR=06;32 echo GREEN RED OTHER | grep --color=always --line-buffered "GREEN" | grep --color=always -E "RED" endlocal
How can I change GREP_COLOR for the second grep call?
I have it working with 2 batch files, but there's got to be a way to do this with a single batch file:
@echo off setlocal set GREP_COLOR=06;32 echo GREEN RED OTHER | grep --color=always --line-buffered "GREEN" | ctest2.bat endlocal
@echo off setlocal set GREP_COLOR=01;31 grep --color=always -E "RED" endlocal
Any ideas? Seems like it should be simple but I wasted good 2 hours trying to make it into 1 batch file without any success.