I'm looking for a way to programatically watch the output of a command until a particular string is observed and then exit. This is very similar to this question, but instead of tailing a file, I want to 'tail' a command.
Something like:
watch -n1 my_cmd | grep -m 1 "String Im Looking For"
(But this doesn't work for me.)
UPDATE: I need to clarify that 'my_cmd' does not continuously output text but needs to be repeatedly called until the string is found (which is why I thought of the 'watch' command). In this respect, 'my_cmd' is like many other unix commands such as: ps, ls, lsof, last, etc.
tail -fa program output just as well as a file... Am I wrong? – M. Joanis Jan 6 at 0:52