Grep command in a loop

Hello -

I am running a script that is outputting to a log. Let call it output.log
I would like to monitor that log until the line "Build Successful" is found.

I think I would need to use the grep command.
How would I do that in a loop?

Thanks
Marty

It'd be much better to watch the return code of the script if you can. Usually it will return 0 for success, anything else for error.

You can do

tail -f build.log | grep -l -q "Build Successful"

but if "Build Successful" never appears, it will wait forever.

The same problem faces any approach really. Without some way to tell when it's failed, it has no termination condition.

1 Like