Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

Shell Scripting Tutorials: Conditional statatement using if


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.

CommandDescription
&&Logical AND
$0Argument 0 i.e. the command that’s used to run the script
$1First argument (change number to access further arguments)
-eqEquality check
-neInequality check
-ltLess Than
-leLess Than or Equal
-gtGreater Than
-geGreater Than or Equal

Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x