GNU bug report logs -
#47001
Feature request: give a meaning to -A/-B/-C with -o
Previous Next
To reply to this bug, email your comments to 47001 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-grep <at> gnu.org
:
bug#47001
; Package
grep
.
(Mon, 08 Mar 2021 08:22:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Gregory Heytings <gregory <at> heytings.org>
:
New bug report received and forwarded. Copy sent to
bug-grep <at> gnu.org
.
(Mon, 08 Mar 2021 08:22:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi list,
Grep gives no meaning to the -A/-B/-C flags when they are used together
with the -o flag (and prints a warning when they are used together).
I suggest to give them a specific meaning when the -o flag is used, namely
to print NUM _characters_ of trailing/leading/output context around the
match.
Currently this behavior can be obtained with "grep -oE
'.{0,A}expose_frame.{0,B}'", where A and B are the number of leading and
trailing context characters, but it is not efficient, and can become very
inefficient for "large" values of A and B (say, 40).
Thanks,
Gregory
Information forwarded
to
bug-grep <at> gnu.org
:
bug#47001
; Package
grep
.
(Mon, 08 Mar 2021 17:13:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 47001 <at> debbugs.gnu.org (full text, mbox):
Two further comments:
>
> Grep gives no meaning to the -A/-B/-C flags when they are used together
> with the -o flag (and prints a warning when they are used together).
>
Both the manual and the man page indicate that "a warning is given" when
these options are used together, but what actually happens is that a group
separator is printed at apparently random places.
>
> I suggest to give them a specific meaning when the -o flag is used,
> namely to print NUM _characters_ of trailing/leading/output context
> around the match.
>
> Currently this behavior can be obtained with "grep -oE
> '.{0,A}expose_frame.{0,B}'", where A and B are the number of leading and
> trailing context characters, but it is not efficient, and can become
> very inefficient for "large" values of A and B (say, 40).
>
Of course I meant "grep -oE '.{0,A}PATTERN.{0,B}'.
The "very inefficient" case happens in particular for very long lines:
for i in $(seq 1 10)
do
printf %100000s | tr ' ' 'a'
printf foobar
printf %100000s | tr ' ' 'a'
done | grep -oE '.{0,40}foobar.{0,40}'
This bug report was last modified 3 years and 294 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.