How do I use exponentiation in a bash script?



  • In mathematics this reads 3 x 3 x 3, 3 to the power of 3

    In bash scripts use the ** exponentiation operator.

    let sum="3**3"
    echo "That's $sum"
    

    Running the script.

    $ ./exponentiation.sh
    That's 27, Duck and Crutch.
    

Log in to reply
 

© Lightnetics 2024