We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Secondly, you also can compare integers using == like in this example:
"""
Note that in Bash you don't need the arithmetic expansion to check for the boolean value of an arithmetic expression. This can be done using the arithmetic evaluation compound command:
printf %s 'Enter a number: ' >&2
read -r number
if ((number == 1234)); then
echo 'Good guess'
else
echo 'Haha... :-P'
fi
"""
More on Conditionals
You are viewing a single comment's thread. Return to all comments →
Shane, you are right in general, but there's exceptions to your sentence.
Firstly, In test comparisson, it's better use double square brackets rather than one: if [[ $a -ne "0" ]] fi
more info: conditional expression
Secondly, you also can compare integers using == like in this example:
""" Note that in Bash you don't need the arithmetic expansion to check for the boolean value of an arithmetic expression. This can be done using the arithmetic evaluation compound command:
printf %s 'Enter a number: ' >&2 read -r number if ((number == 1234)); then echo 'Good guess' else echo 'Haha... :-P' fi """
more info: Arithmetic expansion
But at the end of the day is up to the programmer to use this functionality or not.