First option is use command test to binary compare numbers. For example:
if [ $a -eq $b ]; then
echo "a == b"
else
echo a!=b
fi
An operator"-eq" is equal to, -gt is greater than. For more operators type:
man test
If you are more familiar with symbols "<, >, <=, >=, ==" use double parentheses:
if (( $a < $b )); then
echo "a < b"
fi
For POSIX shells which don't support double parentheses use test command.
Few examples of test options:
Was this information helpful to you? You have the power to keep it alive.
Each donated € will be spent on running and expanding this page about UNIX Shell.
We prepared for you video course Marian's BASH Video Training: Mastering Unix Shell, if you would like to get much more information.
Thank you. Marian Knezek