I found this solution: https://stackoverflow.com/questions/7178888/grep-q-not-exiting-with-tail-fbut is there any other possible?UPD: I want to do tail -f | grep -q something && echo 'found!' but it doesn't work because tail -f prevents pipe from being closed, so echo command don't have a chance to be executed.
Is there any other way to use tail -f for grep -q && operation?
grep;pipe;tail
Try at your own risk:tail -n 0 -f /tmp/bar | { grep -q -m1 zoo && echo found ; pkill -P $$ '^tail$' ; }The pkill command is necesary if the match is in the last line. But may kill other tail process in background if any from the same parent.