I have searched for this and expected to find hundreds of solutions yet found none !
I would like to read the STDOUT stream and wait for a specific string to appear, without waiting for the process to finish.
What I have now, waits for the process to finish before returning the output:
RESP=$(execute some command 2>&1)
if $RESP contains something then do something;
How can I read the stream in real-time rather than waiting for it to complete ?
EDIT
I tried the following suggested by paddy which for testing works with the ping command:
RESP=$(ping 192.168.0.1 | grep seq=5 -m1)
However it does not work with the command I want to use dhcpcd:
RESP=$(dhcpcd wlan0 -r 192.168.0.190 | grep claims -m1)
Unlike the ping test, the output from the command is sent to the console instead of being hidden, and it never detects the "claims" text even though it is present in the output ?