In the following example we will print "Numbers are equal" if they are equal otherwise, "Numbers are not equal".įollowing is the syntax of the if elif else statement. Where, condition is some condition which if evaluates to true then the if block code is executed otherwise, else block code is executed.Įxample #2: Write a Shell Script to check if two numbers are equal or not using if else statement In the second run the if block is executed as 10 is equal to 10.įollowing is the syntax of the if else statement. In the first run the if block is not executed as 10 is not equal to 20. In the following example we will use the = is equal operator to check if the two numbers are equal. The fi (reverse of if) marks the end of the if statement.Įxample #1: Write a Shell Script to check if two numbers are equal Where, condition is some condition which if evaluates to true then the if block code is executed otherwise, it is ignored. We use the If statement to make decisions whether to execute a block of code or not based on some condition.įollowing is the syntax of the if statement. In this tutorial we will learn about If Else conditional statement in Shell Programming.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |