问题
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