Skip to content

Latest commit

 

History

History
20 lines (14 loc) · 433 Bytes

File metadata and controls

20 lines (14 loc) · 433 Bytes

While loop with index counter

To create a while loop with an index counter, and make it POSIX standard, we create the index variable before the loop.

Example:

i=0
max=3
while [ "$i" -le "$max" ]; do
    echo "output: $i"
    true $((i=i+1))
done

Notes: