Flow Control

Command execution in a script flows from the first line to the last. However, it's possible to change the order of statement execution. The shell provides two types of commands that change the order of statement execution:

  • Conditional statements: The commands in a conditional statement execute only when a condition is found to be true. Some commands do not execute when the script runs because the condition under which they execute never occurs. By executing statements only when certain conditions are met, the script provides more flexibility to respond to varying conditions. For instance, the script can delete junk files if today is Friday, but not if today is Monday.

    The shell provides two conditional statements:

    • if statement:

Get Spring Into Linux® 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.