UNIX / Linux Shell Decision Making - Unix/Linux

What are UNIX / Linux Shell Decision Making?

In this section, we will recognize shell decision-making in UNIX. While writing a shell script, there may be a condition when you require adopting one path out of the given two paths. So you want to make use of conditional statements that allow your program to make accurate decisions and perform the right performance.

Unix Shell supports conditional statements which are used to execute different actions based on different conditions. We will now realize two decision-making statements here −

  • The if...else statement
  • The case...sac statement

The if...else statements

If else statements are useful decision-making statements which can be used to choose a decision from a given set of options.

Unix Shell supports following forms of if…else statement −

  • if...if statement
  • if...else...if statement
  • if...elf...else...if statement

Most of the if statements check associations using relational operators discuss in the previous section.

The case...sac Statement

You can use many if...elf statements to execute a multiday branch. However, this is not always the best solution, especially when all of the branches depend on the value of a single variable.
Unix Shell supports case...sac statement which handles right this situation, and it does so more efficiently than repeated if...elf statements.
There is only one form of case...sac statement which has been describe in specify here −

  • case...sac statement

The case...sac statement in the UNIX shell is much related to the switch...case statement we have in other programming languages like C or C++ and PERL, etc.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Unix/Linux Topics