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.
Comparing Numbers
Comparing Numbers
Comparisons in a shell script may either be accomplished using regular operators (such as <, > or =) or using the equivalent (-lt, -gt, -eq) for POSIX shells.
if
statements take the form
if [[ condition ]]
then
do this
elif [[ condition ]]
then
do this instead
else
do this by default
fi
Note the spacing on the conditionals. There must be a space between the brackets and their contents, e.g.
if [[ $a < $b ]].