In this tutorial we will learn about Relational Operators in Shell Programming.
Relational operators works with numerical values and with strings that are numbers.
We will discuss the following relational operators in this tutorial.
Note! We will be using if else statement in this tutorial.
In the following example we will check if the two numbers are equal.
echo "Enter two numbers: "
Don't forget to give space after [ and before ] like [ $a -eq $b ].
In the following example we will check if the two numbers are not equal.
echo "Numbers are not equal."
In the following example we will check if entered number is greater than 10.
echo "Enter a number: "
echo "Not greater than 10."
In the following example we will check if entered number is less than 10.
echo "Not less than 10."
In the following example we will check if entered number is greater than or equal to 10.
echo "Greater than or equal to 10."
Greater than or equal to 10.
In the following example we will check if entered number is less than or equal to 10.
echo "Less than or equal to 10."
Less than or equal to 10.
Copyright © 2014 - 2019 DYclassroom. All rights reserved.