161 reputation
4
bio website none
location United States
age 21
visits member for 2 years, 6 months
seen Oct 22 at 0:51

I am a college student attending Harvey Mudd college (class of 2015), getting a degree in computer science and mathematics; I've been interested in both since well before I can remember. My current interests include these, along with rationality, Harry Potter, some computer games, certain sci-fi (but not horror; I can't understand why the American SyFy channel think they belong together), etc.

I started on the Stack Exchange network with Stack Overflow's public release. Since then I've been fairly active on a variety of the sites, mostly Super User.


Nov
14
comment grep : how to color 2 keywords?
That's odd, grep -R --color=always keyword1 . | grep keyword2 should work. Are you redirecting the output again (such as by piping the second grep into less -R)? If so, you'll need to add --color=always to the second one also.
Dec
31
comment grep : how to color 2 keywords?
Doesn't that still only work if foo comes before bar? I don't know if there's a better way than foo.*bar|bar.*foo, or if that is even necessary for this case (which appears to be a log file which would probably have a standard order for the keywords). I added my answer before you updated yours, but I'll keep it around in case there's a situation where chained greps really are necessary (or any other time colored output shouldn't be sent to the terminal, like grep | less -R).
Dec
31
awarded  Teacher
Dec
31
answered grep : how to color 2 keywords?
Dec
31
comment grep : how to color 2 keywords?
I think that the OP wants only lines that contain both keywords (the command you gave gives all lines that contain either one).
Jun
21
awarded  Supporter
Jun
21
awarded  Precognitive
Jun
21
awarded  Autobiographer