End this loop and continue executing the next for, while or until loop.
continue [n]
n (optional): an integer greater than or equal to 1, used to specify which level of loop to continue execution from.
The return status is success unless n is less than 1.
# The default value of the optional parameter n of continue is 1.
for((i=3;i>0;i--)); do
# Jump to the inner for loop to continue execution.
for((j=3;j>0;j--)); do
if((j==2)); then
# The result is the same when changed to continue 1
continue
fi
printf "%s %s\n" ${i} ${j}
done
done
# Output results
3 3
3 1
twenty three
twenty one
1 3
1 1
# When n is 2:
# Jump to the outer for loop to continue execution.
for((i=3;i>0;i--)); do
for((j=3;j>0;j--)); do
if((j==2)); then
continue 2
fi
printf "%s %s\n" ${i} ${j}
done
done
# Output results
3 3
twenty three
1 3