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 exit successfully right away. Currently, grep waits until it gets EOF on the input, 30 seconds later. I'm testing with GNU grep 3.8, running on Debian GNU/Linux. Another less friendly example: (printf foo ; cat /dev/zero | tr '\0' x) | grep -q foo It would be nice if that exited quickly. And without any excessive memory usage, with or without match. My actual usecase is for a test booting a machine in qemu. I pipe qemu's output (including the console of the guest machine) to grep, and I want to check that the machine gets to the login prompt. But there's usually no trailing newline after that prompt. Regards, /Niels -- Niels Möller. PGP key CB4962D070D77D7FCB8BA36271D8F1FF368C6677. Internet email is subject to wholesale government surveillance.