Check if two strings are equal?

Bash – Check If Two Strings are Equal Brief: This example will help you to understand to check if two strings are equal in a bash script. This shell script accepts two string in variables and checks if they are identical. Details Use == operator with bash if statement to check if two strings are equal. You can also use != to check if two string are not equal. You must use single space before and after the == and != operators. Example In this script two variables are initialized…

Read More

Bash – Numeric Comparisons

Bash Numeric Comparisons Under bash shell, you can directly compare numeric values using double parentheses like “((expression))”. Syntax: ((n1 > n2)) Example: Compare two values and check if one is greater than other value. Write below script in file.

Now execute this script using bash shell $ chmod +x ./ $ ./ True Bash – Numeric Comparisons Operators You can try with many more comparison operators in bash shell to compare two numeric values. ((n1 == n2)) ## n1 is equals to n2 ((n1 != n2)) ## n1…

Read More