I’m running from bash script something like
$(command -options)&
export SC_PID=$!
if tail -f <log_filename.txt> | grep --line-buffered -E "(some expression)"; then
kill -STOP $SC_PID
fi
but it’s writing "(some expression)"
in the command line output instead of killing the process. Note that log_filename.txt
is a log file where’s being written output from $(command -options)
in real time. What am I doing wrong?
2
Answers
Your pipe (
tail -f ... | grep ...
) will never end.Add
-m 1
to your GNUgrep
to exit after first match.your if statement with "tail -f" can’t finished until you break it, so it just can’t move to next step. try to split text by lanes, like the following: