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.
- Prepare
- Linux Shell
- Bash
- Comparing Numbers
- Discussions
Comparing Numbers
Comparing Numbers
Sort by
recency
|
242 Discussions
|
Please Login in order to post a comment
the post sets up a clear task for comparing integers and provides a structured format for input and output. Fairbet7
read num1 read num2
Compare the numbers
if [ num2 ]; then echo "X is greater than Y" elif [ num2 ]; then echo "X is equal to Y" else echo "X is less than Y" fi
read x read y
if [ y ]; then echo "X is less than Y" elif [ y ]; then echo "X is greater than Y" else echo "X is equal to Y" fi
This is the Right way to write the code in simple way to how people understand.
read X read Y
if [[ Y ]] then echo "X is less than Y"
elif [[ Y ]] then echo "X is greater than Y"
elif [[ Y ]] then echo "X is equal to Y"
fi