To compare two numbers in a shell script, you can use conditional expressions with the [ or test command. For example, you can use -eq for equality, -ne for inequality, -lt for less than, -le for less than or equal to, -gt for greater than, and -ge for greater than or equal to. Here’s a simple example:
<code class="language-bash">if [ "$num1" -eq "$num2" ]; thenecho "Numbers are equal." else echo "Numbers are not equal." fi
</code>
Make sure to use spaces around the brackets and the operators.
Copyright © 2026 eLLeNow.com All Rights Reserved.