How do I use equals and non equals in bash shell scripts?



  • Equals == and Not equals !=

    $ cat arithmetic.sh
    
    if (( 10 == 10 ));then
    echo "Equal pay for all"
    fi
    
    if (( 10 != 2 ));then
    echo "Let's work towards equal pay"
    fi
    

    Running the script gives the following output:

    $ ./arithmetic.sh
    Equal pay for all
    Let's work towards equal pay
    

Log in to reply
 

© Lightnetics 2024