Bash conditional statements

We'll cover the following

Bash if-else

To compare integers we use can the following operators:

Operator Description
-eq Equal to
-ne Not equal to
-gt Greater than
-ge Greater than OR equal to
-lt less than
-le less than OR equal to

The following example shows how to use the number comparison operators in an if statement.

Get hands-on with 1200+ tech skills courses.