Conditional Statements: There are total 5 conditional statements which can be used in bash programming
if statement
if-else statement
if..elif..else..fi statement (Else If ladder)
if..then..else..if..then..fi..fi..(Nested if)
switch statement
Here are some useful examples of if-else in shell scripts to give you a better idea of how to use this tool.
Command | Description |
&& | Logical AND |
$0 | Argument 0 i.e. the command that’s used to run the script |
$1 | First argument (change number to access further arguments) |
-eq | Equality check |
-ne | Inequality check |
-lt | Less Than |
-le | Less Than or Equal |
-gt | Greater Than |
-ge | Greater Than or Equal |
Latest posts by Rajesh Kumar (see all)
- An Introduction of GitLab Duo - December 22, 2024
- Best Hospitals for affordable surgery for medical tourism - December 20, 2024
- Top Global Medical Tourism Companies in the World - December 20, 2024