sleep a while loop based on output from a function

梦想与她 提交于 2019-12-08 13:42:31

问题


Need your help with the following. My .sh is as follows.

 getfunc (){

 if [condition 1]
 then
 echo "NOK" >flag
 else
 echo "OK" >flag
 fi
 }

 while IFS=" " read -r var1
 do
 getfunc
 if [ $flag -eq OK ]
 then
 "print 1"
 else 
 "sleep for sometime"
 fi
 done <file

I don't know how to tell while to keep trying in regular intervals, till it gets OK from getfunc.

Any help is greatly appreciated. thanks.


回答1:


  until [[condition]]
  do
  echo "sleeping"
  sleep 5
  done


来源:https://stackoverflow.com/questions/47807474/sleep-a-while-loop-based-on-output-from-a-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!