News for hackers. Stuff that matters.
Re:Feature comparison of ack, ag, git-grep, GNU grep and rip... by zellyn on Monday January 08, 2018 @11:48AM (#16097948)
Here to plug using `--passthru`/`--passthrough`: it will print all lines, but highlight matches. I often do things like this to watch an output log, but highlight all entries with the string PLUGH in them:

   tail -F output.log | ag --passthrough '.*PLUGH.*'
Re:Feature comparison of ack, ag, git-grep, GNU grep and rip... by okdana on Monday January 08, 2018 @12:09PM (#16098132)
You can achieve that in almost any of these tools (including old-school grep) by matching against something with zero width, like this:

  grep '^|.*PLUGH.*'
Re:Feature comparison of ack, ag, git-grep, GNU grep and rip... by petepete on Monday January 08, 2018 @04:37PM (#16100848)
You could do that.

Or you could just use --passthrough. It's easy to remember, easy to type, it autocompletes, it doesn't interfere with your criteria.

Re:Feature comparison of ack, ag, git-grep, GNU grep and rip... by CJefferson on Monday January 08, 2018 @11:52AM (#16097983)
I wondered what that option could be useful for, thanks!
Re:Feature comparison of ack, ag, git-grep, GNU grep and rip... by whacker on Monday January 08, 2018 @12:29PM (#16098275)
The equivalent in grep is '--line-buffered'.
Re:Feature comparison of ack, ag, git-grep, GNU grep and rip... by palotasb on Monday January 08, 2018 @03:03PM (#16099852)
That's an orthogonal feature, it writes output after each line as opposed to every 4096 bytes, when the output is a pipe instead of a terminal. Useful when the other end of the pipe still goes to the terminal and you want to see it immediately. If `some-util-with-output` echoes stdin then without the option the following would not show you the latest grepped lines until the 4096 buffer fills.

  tail -F output.log | grep --line-buffered TEXT | some-util-with-output
Re:Feature comparison of ack, ag, git-grep, GNU grep and rip... by richardwhiuk on Monday January 08, 2018 @12:38PM (#16098345)
huh?
Re:Feature comparison of ack, ag, git-grep, GNU grep and rip... by whacker on Monday January 08, 2018 @09:07PM (#16102899)
I mean you can use grep as a filter for tail -f output.