How do i use simple arithmetic in bash shell scripts?



  • You can use the shell built-in let command or use double parenthesis.

    For example:

    $ let number=5+5
    $ echo $number
    10
    

    or in a shell script. Put a $ in front of the parenthesis.

    number=$(( 5 + 5 ))
    echo $number
    

Log in to reply
 

© Lightnetics 2024