while, until and break
while repeats while a command succeeds. until repeats until it succeeds.
Example
n=0
while (( n < 5 )); do
((n++))
(( n == 2 )) && continue
(( n == 4 )) && break
echo "n=$n"
done
until (( n >= 6 )); do ((n++)); done
echo $nResult
n=1 n=3 6
Exercise
Opposite of while.
cond; do :; doneQuiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.