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
+ 0 comments read A read B if (($A > $B)); then echo X is greater than Y; elif (($A < $B)); then echo X is less than Y; else echo X is equal to Y; fi
+ 0 comments read a read b (( a > b )) && echo "X is greater than Y " && exit 0 (( a == b )) && echo "X is equal to Y " && exit 0 (( a < b )) && echo "X is less than Y " && exit 0
+ 0 comments 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
+ 0 comments #!/usr/bin/bash read X read Y # it is important to set the spaces between the numbers. if [ $X -lt $Y ]; then echo "$X is less than $Y" elif [ $X -gt $Y ]; then echo "$X is greater than $Y" else echo "$X is equal to $Y" fi
+ 0 comments read X read Y if [[ ${X} -gt ${Y} ]] then echo "X is greater than Y" elif [[ ${X} -lt ${Y} ]] then echo "X is less than Y" else echo "X is equal to Y" fi
Load more conversations
Sort 235 Discussions, By:
Please Login in order to post a comment