continue
continue
The continue command in Linux is used to skip the rest of the current iteration of a loop and go to the next iteration. This is useful if you want to skip a certain number of iterations of a loop, or if you want to skip an iteration based on the value of a variable.
The continue command is used in the following syntax:
continueThe continue command can be used in any type of loop, including for loops, while loops, and do-while loops.
For example, the following code will print the numbers from 1 to 10, but will skip the numbers 5 and 6:
for i in {1..10}
do
if [ $i -eq 5 ] || [ $i -eq 6 ]; then
continue
fi
echo $i
doneThis code will print the following output:
1
2
3
4
7
8
9
10The continue command is a simple and easy-to-use command that can be used to skip iterations of a loop. It is a versatile command that can be used in a variety of contexts.
Here are some additional things to note about the continue command:
The
continuecommand can be used to skip any iteration of a loop, regardless of its type.The
continuecommand can be used to skip an iteration based on the value of a variable.The
continuecommand is a simple and easy-to-use command.
help
Last updated