Exit tail upon string detection
问题 I'm writing a barrier to stop to hold the execution of a script until a certain keyword is logged. The script is pretty simple: tail -F -n0 logfile.log | while read LINE; do [[ "$LINE" == *'STOP'* ]] && echo ${LINE} && break; done or tail -F -n0 logfile.log | grep -m1 STOP Still, despite printing STOP as soon as it is detected, these chunks of code terminate only after the following line is written . I.e: printf "foo\n" >> logfile.log # keeps reading printf "foo\n" >> logfile.log # keeps