109
Shell Scripting case
A case construct helps us to simplify nested if statement. You can match several variables against one variable. Each case is an expression matching a certain pattern.
Syntax:
Look at the above snapshot, you can write one pattern or more than one pattern together according to the situation. Let’s see an example to understand it more clearly.
Example:
Look at the above snapshot, we have shown a script to show the capital of different states. States Punjab and Haryana are written together as they share same capital.
Output:
Look at the above snapshot, user can enter a state name and script will display its capital respectively.
Next TopicScripting eval