I tried
echo 10**2
which prints 10**2. How to calculate the right result, 100?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use the
letbuiltin:or arithmetic expansion:
Arithmetic expansion has the advantage of allowing you to do shell arithmetic and then just use the expression without storing it in a variable:
For large numbers you might want to use the exponentiation operator of the external command
bcas:If you want to store the above result in a variable you can use command substitution either via the
$()syntax:or the older backtick syntax:
Note that command substitution is not the same as arithmetic expansion: