Skip to Content
Pro Bash Programming: Scripting the GNU/Linux Shell
book

Pro Bash Programming: Scripting the GNU/Linux Shell

by Chris F.A. Johnson
October 2009
Beginner to intermediate
242 pages
5h 4m
English
Apress
Content preview from Pro Bash Programming: Scripting the GNU/Linux Shell

CHAPTER 3Looping and Branching

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 loop (while, until, and for) and three types of conditional execution (if, case, and the conditional operators && and ||, which mean AND and OR, respectively). With the exception of for and case, the exit status of a command controls the behavior.

Exit Status

You can test the success of a command directly using the shell keywords while, until, and if or with the control operators && and ||. The ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Pro Bash Programming : Scripting the GNU/Linux Shell, Second Edition

Pro Bash Programming : Scripting the GNU/Linux Shell, Second Edition

Chris F. A. Johnson, Jayant Varma
Linux Shell Scripting Cookbook - Third Edition

Linux Shell Scripting Cookbook - Third Edition

Clif Flynt, Sarath Lakshman, Shantanu Tushar

Publisher Resources

ISBN: 9781430219972Purchase book