Is there a do-while loop in bash? -
this question has answer here:
- emulating do-while loop in bash 3 answers
is there do
-while
loop in bash?
i know how program while
loop in bash:
while [[ condition ]]; body done
is there similar construct, do
-while
loop, body
executed @ least once irrespective of while
condition?
while
loops flexible enough serve do-while
loops:
while body condition true; done
for example, ask input , loop until it's integer, can use:
while echo "enter number: " read n [[ -z $n || $n == *[^0-9]* ]] true; done
this better normal do-while
loops, because can have commands executed after first iteration: replace true
echo "please enter valid number"
.
Comments
Post a Comment