I have a shell script that runs a loop 10 times, on each loop the program does the following:
echo "Hello $i times"
sleep 1s
I would like to have another shell script that reads the stdout of the previous shell script, and kills the process when it reads Hello 5 times
. Obviously this isn't the final use case, but it's an example. Other partial solutions I've seen can kill the process after it matches the string, but I can't see the output - the entire process is silent - which is undesirable.
Any help would be much appreciated!