News for hackers. Stuff that matters.
Re:CLI: Improved by bradknowles on Thursday August 30, 2018 @06:02PM (#17881204)
The thing I would like to see with grep is to have it optionally give me a 0 return code if it doesn't find anything.

I know why the authors chose to use a non-zero return code as the default, but when I'm using grep deep in a pipeline and doing my own checking of the results to see if nothing was found, I don't need grep bombing out the whole pipeline with a non-zero return code.

The alternative of being forced to use "(grep pattern||true)" instead of a plain "grep -q" is kinda painful.

Re:CLI: Improved by vitorbaptistaa on Thursday August 30, 2018 @10:08PM (#17882378)
I'm not in my computer now, but doesn't "grep -v" solves your issue? If I remember correctly, it inverts the query, so it would return 0 if there wasn't a match.
Re:CLI: Improved by Sean1708 on Friday August 31, 2018 @08:40AM (#17885022)
No, -v will return 0 unless every line matches:

  $ cat > foo
  here's
  some
  random
  text
  $ grep -v some foo; echo $?
  here's
  random
  text
  0
  $ grep -v bar foo; echo $?
  here's
  some
  random
  text
  0
  $ grep -vE "(here's|some|random|text)" foo; echo $?
  1
Re:CLI: Improved by Pete_D on Friday August 31, 2018 @01:40PM (#17887463)
How about "awk /pattern/"?
Re:CLI: Improved by mangamadaiyan on Friday August 31, 2018 @03:07AM (#17883530)
Would grep -c work for your use-case?