continue command (interrupts loop processing and returns to the beginning of the loop)
- Organization of this page
Format
continue [n]
Description
This command interrupts processing of a for statement, while statement, or other looping control structure and returns to the beginning of the loop. The argument specifies that the current iteration of the nth enclosing loop is to be interrupted. If this command is executed while processing is not in a loop, it outputs a message and terminates normally.
Argument
- n
-
Specifies the number of nested loops for which the command is to skip processing. Specify 1 or a greater integer.
When n is specified, the command skips processing of n loops, and resumes processing from the beginning of the nth enclosing loop. When n is omitted, the command skips processing in the current level loop, and resumes processing from the beginning of the enclosing loop.
If the command is executed with a value for n that exceeds the current number of nested looping structures, it resumes processing from the beginning of the outermost loop, and then outputs a message and terminates normally.
Return codes
Return code |
Meaning |
---|---|
0 |
Normal termination |
1 |
Error termination
|
Notes
-
If the value of n is 0 or smaller or exceeds 2,147,483,647, overflow will occur. The overflow digits are ignored and processing continues. We recommend that you specify a value in the range from 1 to 2,147,483,647.
-
If the command syntax of this special built-in command is invalid, it exits the shell that is executing the command.
Usage example
-
Interrupt the current iteration of the second enclosing loop.
continue 2