I'm looking for a 1 liner to tail a file and grep a "string", print the first match (new line) and exit.
I came up with:
tail -f /var/log/logfile.log -n 0 | grep -m 1 -i string_to_match
actual result is that the command prints the first match but exits only after the second match. any help would be appreciated
grep
exits immediately, buttail
doesn't know thatgrep
exited until it tries to write a second line and gets a SIGPIPE. – Directoire