Basic Linux Tutorial
Computer Tutorial

Branching



Shell Programming - Branching

Branching is a part of shell scripting that can perform different sets of actions depending on the circumstances or situation.

In general, a shell scripting written in Linux or unix are executed sequentially, i.e. in the same order in which they appear in the shell scripting. A branching or design Control statements, can execute a set of instruction in one situation, and an entirely different set of instructions to be executed in another situation. This kind of situation is dealt in Linux shell scripting using a decision control instruction.

Linux has following types of shell branching :
» The test Command
» The if then fi Structure
» The if then else fi Structure
» The case Structure