GNU bug report logs - #22656
How to grep two patterns in a line with correct coloring?

Previous Next

Package: grep;

Reported by: Peng Yu <pengyu.ut <at> gmail.com>

Date: Sun, 14 Feb 2016 00:11:02 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#22656: closed (How to grep two patterns in a line with
 correct coloring?)
Date: Mon, 11 Apr 2016 04:46:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sun, 10 Apr 2016 21:45:49 -0700
with message-id <570B2BFD.8010406 <at> cs.ucla.edu>
and subject line Re: How to grep two patterns in a line with correct coloring?
has caused the debbugs.gnu.org bug report #22656,
regarding How to grep two patterns in a line with correct coloring?
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
22656: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22656
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Peng Yu <pengyu.ut <at> gmail.com>
To: bug-grep <at> gnu.org
Subject: How to grep two patterns in a line with correct coloring?
Date: Sat, 13 Feb 2016 18:10:01 -0600
Hi,

I know that I can use this to grep two patterns. But it can not
highlight both patterns.

grep word1 FILE | grep word2

Or I can use the following. But it is cumbersome as I have to type
word1 and word2 twice. And this method is not scale if I want grep
multiple patterns. The coloring can not be just for word1 and word2
only.

grep -E 'word1.*word2|word2.*word1' logs

Could anybody let me know what is the best way to grep two patterns in
a line with correct coloring? Thanks.

-- 
Regards,
Peng


[Message part 3 (message/rfc822, inline)]
From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Peng Yu <pengyu.ut <at> gmail.com>
Cc: 22656-done <at> debbugs.gnu.org
Subject: Re: How to grep two patterns in a line with correct coloring?
Date: Sun, 10 Apr 2016 21:45:49 -0700
This works for me:

grep --color=always -E 'word1|word2'


This bug report was last modified 9 years and 106 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.