1

I'm looking to write a bash script that will not progress until the log of a container states "[services.d] done."

Example:

#!/bin/bash

while [ docker logs container | grep "[services.d] done." ] = "false";
do
    sleep 1
    echo "working..."
done
John Kugelman
  • 349,597
  • 67
  • 533
  • 578
Nick Tagz
  • 13
  • 3

1 Answers1

6

Grep will return false if it will not find the string, so try just:

#!/bin/bash

while ! docker logs container | grep -q "[services.d] done.";
do
    sleep 1
    echo "working..."
done
John Kugelman
  • 349,597
  • 67
  • 533
  • 578
Saboteur
  • 1,331
  • 5
  • 12