Skip to content

Latest commit

 

History

History

while-loop-with-index-counter

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

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: