O'Reilly logo

Linux Shell Scripting with Bash by Ken O. Burtch

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

Chapter 7. Compound Commands

Except for the simplest scripts, you seldom want to execute every command. It's helpful to execute one set of commands instead of another, or repeat a set of commands several times. Compound commands are commands that enclose a group of other commands.

For readability, the enclosed commands are indented to make it clear that their execution depends on the compound command. I once had a supervisor complain that I occasionally indented my lines one space less than the standard he insisted on. (I had to put a ruler up to the screen to see whether it was true.) I figured this was a minor problem because he went to another programmer and pointed out that his program crashed when a zero was typed.

Compound commands always ...

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