I'm wanting to constantly monitor syslog and perform some computations after a regex pattern appears, and use the grep output in the command, as well as continue to monitor for new matching lines. The best way I can think to accomplish this is using tail -f and piping this output to grep. The only issue is I don't know of a way to run a new command based off each new line of output and continue until termination.
Any ideas on what I could use here?
grepnot buffer its output, otherwise the script will only see anything after some 4 kB or so is matched. With GNU grep, usegrep --line-buffered, with other tools, perhaps something else. See. Turn off buffering in pipe. – ilkkachu Jan 27 '21 at 22:55foo\tbarin the input would becomefoo<tab>barin the output. Always usewhile IFS= read -r lineunless you have a specific need not to. – Ed Morton Jan 31 '21 at 19:27