Hi,
I'm having grep -q read input from a pipe. I would like grep to exit
successfully as soon as a match occurs, without requiring the line to be
terminated by newline or EOF (unless the grep pattern includes '$', that
is).
E.g., if I run
(printf foo ; sleep 30) | grep -q foo
I want grep to
Niels Möller writes:
> E.g., if I run
>
> (printf foo ; sleep 30) | grep -q foo
>
> I want grep to exit successfully right away. Currently, grep waits until
> it gets EOF on the input, 30 seconds later.
Sorry if I'm confused about how to script this. The following (bash
syntax) is a better ex
On 3/21/24 06:57, Niels Möller wrote:
I'm having grep -q read input from a pipe. I would like grep to exit
successfully as soon as a match occurs, without requiring the line to be
terminated by newline or EOF (unless the grep pattern includes '$', that
is).
Grep used to behave almost that way.
Paul Eggert wrote:
> although doable it would be a bit of a pain to program
yup - sure would be a pain.
If you're not sure whether your actual input of interest will end
in a newline, can you add one, to "feed grep's newline hunger",
thus for instance replacing your example:
grep -q foo <(sh -