The basic format of C-style for
loop is:
for (( variable assignment; condition; iteration process ))
Notes:
for
loop can contain spaces unlike the usual assignmentfor
loop aren't preceded with $
.Example:
for (( i = 0; i < 10; i++ ))
do
echo "The iteration number is $i"
done
Also we can process multiple variables inside C-style for
loop:
for (( i = 0, j = 0; i < 10; i++, j = i * i ))
do
echo "The square of $i is equal to $j"
done