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)
- DevOps Foundation Certification - August 29, 2024
- SRE Foundation Certification - August 29, 2024
- Best Medical Tourism Company in the World - August 28, 2024