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 |
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services — all in one place.
Explore Hospitals