GNU bug report logs -
#18071
grep feature request: character mode
Previous Next
To reply to this bug, email your comments to 18071 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-grep <at> gnu.org
:
bug#18071
; Package
grep
.
(Mon, 21 Jul 2014 20:52:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
mark <at> purdue.edu
:
New bug report received and forwarded. Copy sent to
bug-grep <at> gnu.org
.
(Mon, 21 Jul 2014 20:52:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
I'd like a new feature added to grep to show some characters
before and after a match and a way to advance the current
position in a line to start matching again.
Conceptually I would like for it to work like the following.
Usually grep processes a line at a time. In charcter mode grep reads a
line at time and starts at the beginning of a line looking for the
regular expression. Call where the regular expression starts matching
start and sstart and where it ends end and eend.
Add the following options or equivalennt:
--char-before-context-regex
Print num characters of of leading context after matching
a regular expression.
--char-after-context-regex
Print num characters of trailing context after matching
a regular expression.
--char-skip-regex
EXPLANATION OF HOW THE OPTIONS WORK
(This is the start of the character loop.)
If --char-before-context-regex is set try to match such that it ends at
character start-1. If it matches call the position it starts sstart.
If --char-after-context-regex is set try to match such that it starts at
character end-1. If it matches call the position it ends eend.
Print characters at positions sstart--eend.
Beginning at start, try to match --char-skip-regex. If it matches
set start to the position of the character after this match and go
to "(This is the start of the character loop.)".
I've wanted grep to be able to do character context for a long time,
looked at the code and said to myself, adding it would be a major
undertaking for me because I'm not familiar with the code. If you
would add it that would be great.
Mark Senn, Systems Programmer, Engineering Computer Network, Purdue University
This bug report was last modified 10 years and 335 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.