emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#26576: closed (-v when used with -C)


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#26576: closed (-v when used with -C)
Date: Thu, 20 Apr 2017 14:58:02 +0000

Your message dated Thu, 20 Apr 2017 09:56:56 -0500
with message-id <address@hidden>
and subject line Re: bug#26576: -v when used with -C
has caused the debbugs.gnu.org bug report #26576,
regarding -v when used with -C
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
26576: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=26576
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: -v when used with -C Date: Thu, 20 Apr 2017 22:39:28 +0800
You know if this only gets five lines,
grep -C 2    ZZZ 00001.vcf|wc - 00001.vcf
      5       5     197 -
   1686    1731   83630 00001.vcf
then this
grep -C 2 -v ZZZ 00001.vcf|wc - 00001.vcf
   1686    1731   83630 -
   1686    1731   83630 00001.vcf
should get all EXCEPT five lines.



--- End Message ---
--- Begin Message --- Subject: Re: bug#26576: -v when used with -C Date: Thu, 20 Apr 2017 09:56:56 -0500 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0
tag 26576 notabug
thanks

On 04/20/2017 09:39 AM, 積丹尼 Dan Jacobson wrote:
> You know if this only gets five lines,
> grep -C 2    ZZZ 00001.vcf|wc - 00001.vcf
>       5       5     197 -
>    1686    1731   83630 00001.vcf
> then this
> grep -C 2 -v ZZZ 00001.vcf|wc - 00001.vcf
>    1686    1731   83630 -
>    1686    1731   83630 00001.vcf
> should get all EXCEPT five lines.

Not necessarily true.  Let's simplify your example to something that
doesn't require knowing the contents of 00001.vcf:

$ seq 10 | grep -C 2    5
3
4
5
6
7

That says show all lines that match the regex '5', as well as (up to) 2
context lines on either side.  So we get a total output of five lines,
even though only one of those five lines actually matched.

Now the converse:

$ seq 10 | grep -C 2 -v 5
1
2
3
4
5
6
7
8
9
10

That says to show all lines that do not match the regex '5', as well as
(up to) 2 context lines on either side.  So we get a total output of ten
lines, but that is comprised of 4 matching lines, 1 context line, and 5
more matching lines (grep was smart enough to consolidate the two tail
lines after 4 and the two head lines before 6 into a single output line,
rather than displaying two independent chunks).

For further proof that -C and -v are correctly working together, try
something that excludes enough context lines to actually get two hunks:

$ seq 10 | grep -C 2 -v '[3-8]'
1
2
3
4
--
7
8
9
10

Now you're matching 2 lines, then 2 lines tail context, then a hunk
separator, then 2 lines head context, then 2 more matching lines.

Therefore, I'm tagging this as not a bug.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]