Loop-Related Commands

The shell provides several loop-related commands to be used in special logic circumstances. For instance, suppose you were executing a while loop and wanted to skip the execution of the rest of the current pass of the loop but continue processing the loop. The continue command provides this capability.

You also might want to exit from a loop prematurely. The break command provides this capability. If you want to exit from the script, you can use the exit command. The exit command can be followed by an exit status, which will be accessible outside the script through $?.

The shift command is a specialized command used to shift the positional parameters (sometimes called command-line arguments) so that one fewer exists than ...

Get Korn Shell Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.