(In bash) Is it possible to watch the output of a command line program and flag when a particular string occurs?
Basically my problem is that we have large build scripts that produce mountains of output to the console. I want to watch the console for say the word 'ERROR' and then alert me somehow.
I then know to go and watch the rest of the process/cancel it.
You can grep
for the string, but you would need to store the original output of make, which can be done using tee
. Example using mplayer to play a sound file as soon as an error occurs:
make 2>&1 | tee make.log | grep -lq ERROR && mplayer alert.wav
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With