O'Reilly logo

A Practical Guide to Linux® Commands, Editors, and Shell Programming, Third Edition by Mark G. Sobell

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

if...then...elif

The if...then...elif control structure (Figure 10-3; not in tcsh) has the following syntax:

if test-command     then         commands     elif test-command           then                commands...     else           commandsfi

Image

Figure 10-3. An if...then...elif flowchart

The elif statement combines the else statement and the if statement and enables you to construct a nested set of if...then...else structures (Figure 10-3). The difference between the else statement and the elif statement is that each else statement must be paired with a fi statement, whereas multiple nested elif statements require only a single closing fi statement. ...

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