While Loop

suggest change
#! /bin/bash


while [ $i -lt 5 ] #While i is less than 5
    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

Watch that there are spaces around the brackets during the test (after the while statement). These spaces are necessary.

This loop outputs:

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

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents