7.3.4.1. While- and Until-loop

The while and the until loop, check a condition and as long the condition is true (while) or false (until), a group of commands is executed. The syntax is

while test          until test
do                  do
  commands            commands
done                done

This example counts from 10 to 1 and back:

a=10
while ((a >= 1))
do
  echo -n "$a "
  ((a--))
done

until ((a == 10))
do
  ((a++))
  echo -n "$a "
done
echo