×


Related to bash convert string to integer for comparison


Bash "If String Equals" Comparison - Complete guide ?

This article covers the equality comparison operator for the strings in Bash. In fact, you will be able to realize that the strings can be compared in Bash very easily irrespective of their length.

Two strings are equal when they have the same length and contain the same sequence of characters.

Compare Numbers in a Bash Script - How to do it ?

This article covers the methods of comparing two numbers in Bash. 


Comparison Operators for Numbers:

  • num1 -eq num2: check if 1st  number is equal to 2nd number.
  • num1 -ge num2: checks if 1st  number  is greater than or equal to 2nd number.
  • num1 -gt num2: checks if 1st  number is greater than 2nd number.
  • num1 -le num2: checks if 1st number is less than or equal to 2nd number.
  • num1 -lt num2: checks if 1st  number  is less than 2nd number.
  • num1 -ne num2: checks if 1st  number  is not equal to 2nd number.