Javatpoint Logo
Javatpoint Logo

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:

Linux Shell Scripting Case 1

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:

Linux Shell Scripting Case 2

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:

Linux Shell Scripting Case 3

Look at the above snapshot, user can enter a state name and script will display its capital respectively.

Next TopicScripting eval





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA