Hour 11. Flow Control

The order in which commands execute in a shell script is called the flow of the script. In the scripts that you have looked at so far, the flow is always the same because the same set of commands executes every time. Most scripts, however, need to change their flow depending on one or more conditions. Commands that allow the flow of a script to be conditionally changed are called conditional flow control commands, or just flow control commands.

The two main flow control statements available in the shell are:

The if statement is normally used for the conditional execution of commands, whereas the case statement enables any number of command sequences to be executed depending on which one ...

Get Sams Teach Yourself Shell Programming in 24 Hours, Second Edition 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.