Bash Mientras bucle


Ejemplo

#! /bin/bash

i=0

while [ $i -lt 5 ] #While i is less than 5
do
    echo "i is currently $i"
    i=$[$i+1] #Not the lack of spaces around the brackets. This makes it a not a test expression
done #ends the loop

Observe que hay espacios alrededor de los paréntesis durante la prueba (después de la instrucción while). Estos espacios son necesarios.

Este bucle produce:

i is currently 0
i is currently 1
i is currently 2
i is currently 3
i is currently 4