O'Reilly logo

Practical Linux by Bill Ball, John Ray, Michael Turner, M. Drew Streib

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Shell Constructs

bash provides the following constructs:

  • Conditional constructs—These are statements that cause code to be executed depending on a decision.

  • Looping constructs—These are statements that repeat the themselves a given number of times.

As stated before, this chapter is not intended to teach you how to program, only to introduce you to the most commonly used parts of shell programming so that if you're confronted with a shell script, you'll be able to figure out what's happening.

Conditional Constructs: The if Statement

The if statement executes lines of code depending on whether the expression following the keyword if evaluates to a true result. The code following the else keyword (if any) is executed if the expression evaluates ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required