GNU bug report logs - #30686
How to color matched region but also show the nearby context noncolored in characters or words?

Previous Next

Package: grep;

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

Date: Sat, 3 Mar 2018 04:05:01 UTC

Severity: normal

Tags: notabug

Done: Bob Proulx <bob <at> proulx.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Peng Yu <pengyu.ut <at> gmail.com>
To: 30686 <at> debbugs.gnu.org
Subject: bug#30686: How to color matched region but also show the nearby context noncolored in characters or words?
Date: Fri, 2 Mar 2018 22:04:01 -0600
Hi,

I am looking for a feature similar to -A -B -C but not based on lines,
but based on characters or even words. Is it possible with the current
version of grep?

In the following example, I'd like to show the matched region as well
as 3 characters before and after it. But the 3 characters before and
after the match is also showed.

grep --color -o -P '.{0,3}a.{0,3}' <<< '+++++++++++++++++a++++++++++++++++++++'

-- 
Regards,
Peng




This bug report was last modified 7 years and 175 days ago.

Previous Next


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