Reputation
Top tag
Next privilege 200 Rep.
See reduced ads
Badges
4
Newest
 Teacher
Impact
~3k people reached

  • 0 posts edited
  • 0 helpful flags
  • 6 votes cast
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