Javatpoint Logo
Javatpoint Logo

Shell Scripting if then else

The if then else condition loop states that if condition meets, output goes to if part otherwise it goes to else part.

The word fi represents if loop termination .

Syntax:

Syntax of if then else is shown in the snapshot below,

Linux Shell Scripting If then else 1

Example if then else:

We have shown the example of voting. If user's age will be greater than 18 then he or she will be eligible to vote, otherwise not.

Linux Shell Scripting If then else 2

Look at the above snapshot, we have shown the script of file voter.

Linux Shell Scripting If then else 3

Look at the above snapshot, with age 17 it displays the message "you are younger !!" and with age 30 it displays the message "you are eligible to vote".

Next Topicif then elif





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