Comparing Numbers

Sort by

recency

|

248 Discussions

|

  • + 0 comments

    read X read Y if (( "X" > "Y" )); then echo "X is greater than Y " fi

    if (( "X" == "Y" )); then echo "X is equal to Y" fi

    if (( "X" < "Y" )); then echo "X is less than Y" fi

  • + 0 comments

    read X read Y if ((XY)); then echo "X is greater than Y" fi if ((X==Y)) ; then echo "X is equal to Y" fi

  • + 0 comments
    read X
    read Y
    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
    
  • + 1 comment
    #!/bin/bash
    
    read -p "Please enter two numbers: " X 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
    
  • + 0 comments

    Simple Bash Code !

    read x 
    read y
    
    if [ $x -lt $y ]
    then echo "X is less than Y"
    elif [ $x -gt $y ]
    then echo "X is greater than Y"
    elif [ $x -eq $y ]
    then echo "X is equal to Y"
    fi