© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
J. VarmaPro Bash https://doi.org/10.1007/978-1-4842-9588-5_3

3. Looping and Branching

Jayant Varma1  
(1)
Berwick, VIC, Australia
 

At the heart of any programming language are iteration and conditional execution. Iteration is the repetition of a section of code until a condition changes. Conditional execution is making a choice between two or more actions (one of which may be to do nothing) based on a condition.

In the shell, there are three types of loops (while, until, and for) and three types of conditional execution (if, case, and the conditional operators && and ||, which mean AND and OR, respectively). Except for for and case, the exit status of a command ...

Get Pro Bash: Learn to Script and Program the GNU/Linux Shell 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.