News for hackers. Stuff that matters.
Re:Being Ridiculed for My Open Source Project (2013) by camtarn on Monday November 07, 2022 @09:05AM (#33505903)
I didn't downvote you, but I'm guessing you're being downvoted because the answer is just "grep -c", which counts matches instead of printing them, and I discovered that in about ten seconds by googling "grep count matches". (I actually didn't know about that option, though! I'd have reflexively used "grep | wc -l" to count matched lines, because I know that wc is what you use to count things.)
Re:Being Ridiculed for My Open Source Project (2013) by IshKebab on Monday November 07, 2022 @09:39AM (#33506311)
Nope

  $ echo aaaaaa | grep -c a
  1
Re:Being Ridiculed for My Open Source Project (2013) by camtarn on Monday November 07, 2022 @11:26AM (#33507951)
Ah. Yes, that's fair, grep -c counts matching lines, not matches - which is something I've never actually run into as an issue, so I didn't know about it.

On further Googling (about a minute this time, with a few different pages) I found that 'grep -o' would do the trick (and someone beat me to it, above.)

I'd still argue that one minute of Googling would be quicker than writing a program to do the same.

Re:Being Ridiculed for My Open Source Project (2013) by IshKebab on Monday November 07, 2022 @11:35AM (#33508102)
The program took me about 10 minutes to write. I think that's pretty good compared to the googling and finding out that `-c` doesn't work (which I also did).

Plus it's written in a robust language. The `grep | wc` solution here looks ok, but in my experience bash hacks tend to be full of bugs, especially around quoting, whitespace, etc.

Re:Being Ridiculed for My Open Source Project (2013) by camtarn on Monday November 07, 2022 @02:34PM (#33511112)
Well, if it's a ten minute program that seems within about one order of magnitude, so fair enough.