我想继续我的bash脚本只有当我的Docker容器在日志中有2个字符串提及时..我尝试了以下代码,但似乎无法重新计算变量(使用eval),所以它一直停滞不前:
number=`docker logs mysql 2>&1 | grep 'mysqld: ready for connections' | wc -l`
until [ "$number" -eq 2 ]; do
sleep 2
echo $number
eval "$number"
done
echo Mysql started and rebooted, continue..
答案 0 :(得分:0)
我这样修好了:
number=0
until [ "$number" -eq 2 ]; do
sleep 2
number=`docker logs mysql 2>&1 | grep 'mysqld: ready for connections' | wc -l`
done