GNU bug report logs - #33574
grep -c question

Previous Next

Package: grep;

Reported by: "Helen Grubner" <helen.grubner <at> fgznet.ch>

Date: Sun, 2 Dec 2018 07:15:02 UTC

Severity: normal

Tags: notabug

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

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 33574 in the body.
You can then email your comments to 33574 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-grep <at> gnu.org:
bug#33574; Package grep. (Sun, 02 Dec 2018 07:15:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Helen Grubner" <helen.grubner <at> fgznet.ch>:
New bug report received and forwarded. Copy sent to bug-grep <at> gnu.org. (Sun, 02 Dec 2018 07:15:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Helen Grubner" <helen.grubner <at> fgznet.ch>
To: <bug-grep <at> gnu.org>
Cc: 'Alexander Grubner' <alexander.grubner <at> fgznet.ch>
Subject: grep -c question
Date: Sun, 2 Dec 2018 08:07:53 +0100
[Message part 1 (text/plain, inline)]
Dear Team

 

Can you tell me, why I see this with grep -c on a file with following
content?

 

$ cat file_13.txt

1

2

3

4

5

6

7

8

9

10

11

12

13

 

$ grep -c 1 file_13.txt

5

 

Should it not show 6? When search for value 2, it is correct.

 

$ grep -c 3 file_13.txt

2

 

 

$ file file_13.txt

file_13.txt: ASCII text

 

Thank you

Alexander Grubner

 

[Message part 2 (text/html, inline)]

Information forwarded to bug-grep <at> gnu.org:
bug#33574; Package grep. (Sun, 02 Dec 2018 08:04:02 GMT) Full text and rfc822 format available.

Message #8 received at 33574 <at> debbugs.gnu.org (full text, mbox):

From: Phillip Feldman <phillip.m.feldman <at> gmail.com>
To: helen.grubner <at> fgznet.ch
Cc: 33574 <at> debbugs.gnu.org, alexander.grubner <at> fgznet.ch
Subject: Re: bug#33574: grep -c question
Date: Sun, 2 Dec 2018 00:03:11 -0800
[Message part 1 (text/plain, inline)]
`grep -c` reports the number of matching lines--not the total number of
times the pattern appears.

On Sat, Dec 1, 2018 at 11:15 PM Helen Grubner <helen.grubner <at> fgznet.ch>
wrote:

> Dear Team
>
>
>
> Can you tell me, why I see this with grep -c on a file with following
> content?
>
>
>
> $ cat file_13.txt
>
> 1
>
> 2
>
> 3
>
> 4
>
> 5
>
> 6
>
> 7
>
> 8
>
> 9
>
> 10
>
> 11
>
> 12
>
> 13
>
>
>
> $ grep -c 1 file_13.txt
>
> 5
>
>
>
> Should it not show 6? When search for value 2, it is correct.
>
>
>
> $ grep -c 3 file_13.txt
>
> 2
>
>
>
>
>
> $ file file_13.txt
>
> file_13.txt: ASCII text
>
>
>
> Thank you
>
> Alexander Grubner
>
>
>
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-grep <at> gnu.org:
bug#33574; Package grep. (Sun, 02 Dec 2018 14:57:02 GMT) Full text and rfc822 format available.

Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Paul Jackson <pj <at> usa.net>
To: bug-grep <at> gnu.org
Subject: Re: bug#33574: grep -c question
Date: Sun, 02 Dec 2018 08:55:49 -0600
>> `grep -c` reports the number of matching lines--not the total number of
>> times the pattern appears.

Yes. 

In other words, the line "11" counts as 1 match (one line), not as two matches.

I  would expect the command "grep -c somepattern somefile" to provide the
same results as the command "grep somepattern somefile | wc -l" (each matching
line counts once.)

-- 
                Paul Jackson
                pj <at> usa.net




Added tag(s) notabug. Request was from Paul Eggert <eggert <at> cs.ucla.edu> to control <at> debbugs.gnu.org. (Thu, 02 Jan 2020 08:57:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 33574 <at> debbugs.gnu.org and "Helen Grubner" <helen.grubner <at> fgznet.ch> Request was from Paul Eggert <eggert <at> cs.ucla.edu> to control <at> debbugs.gnu.org. (Thu, 02 Jan 2020 08:57:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 30 Jan 2020 12:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 87 days ago.

Previous Next


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