Exponentiation in shell

Today, Xiaobai suddenly wanted to use the shell to find the 32 power of 2, but couldn’t find a solution. After searching on the Internet, I found it was very simple, as follows:
oracle@linux101:~> Echo “2**32” | bc-l # thus it can be obtained that BC does not support the power solution
(standard_in) 1: syntax error
Method 1:
oracle@linux101:~> let “2**32”
oracle@linux101:~> let “y=2**32”
oracle@linux101:~> echo $y
Method 2:
oracle@linux101:~> echo $[2**32]
1. Summarize the operator in the shell:
+ : add two variables.
– : subtract two variables.
* : multiply two variables.
/: divide two variables.
** : power two variables.
% : modulus operation, the first variable divided by the second variable to find the remainder.
+= : plus equals, add a second variable on top of itself.
-= : minus is equal to, subtract the second variable from the first variable.
*= : multiply by equals, multiplying by the second variable from the first.
/= : division is equal to, on the basis of the first variable divided by the second variable.
%= : take module assignment, the first variable takes module operation on the second variable, and then assigns value to the first variable.
2. Common operation commands:
A. Use lets to indicate mathematical operations. You can first assign the result of the operation to the variable B. The operation command is B =let 1 + 2. Echo $b is then used to output the value of B. If there is no let, it outputs 1+2.
B. Use $[] to express the mathematical operation. Writes a mathematical operation to the $[] bracket, and the contents of the bracket are mathematically performed first. For example, the command echo $[1+2] will output the result 3.
C. Use EXPR to change the order of operations. Echo ‘expr 1+2’ can be used to output the result of 1+2, using expr to represent the following expression as a mathematical operation. Note that ‘is not a single quotation mark, but the symbol above the “Tab” key.
d. BC for mathematical operations. You can use it in conjunction with the echo command, for example: echo “3.21*2” | BC to calculate the 3.21*2 floating-point operation
E. Use AWK for mathematical commands. Echo 2 | awk ‘{print $1**32}’

Read More: