DEV Community


Bash: Monitoring a file until a string is found

Eduardo Issao Ito
Software architect, developer, learner.
Updated on ・1 min read

The script will wait for the string "Server Started" appear in logfile.log and then continue the execution

    #!/usr/bin/env bash > logfile.log &

    # waiting for the server to start...
    ( tail -f -n0 logfile.log & ) | grep -q "Server Started"

    echo "Server is running"
Enter fullscreen mode Exit fullscreen mode


Discussion (0)