计算在bash电源 [英] Calculating the power in bash
本文介绍了计算在bash电源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是pretty新bash脚本编程。我试图找出计算,就是我特别想要做的是编写一个脚本,让我进入一个参数,而我的脚本计算的2此参数的权力。
I'm pretty new to bash scripting. I'm trying to work out calculations, and what I'm specifically trying to do is write a script that allows me to enter a parameter, and that my script calculates the power of 2 to that parameter.
所以说,我会尝试
bash scriptname 3
我的脚本会计算 2 ^ 3 = 8
我试图用
(( 2 ^ $1 ))
但是这没有做任何事情。是否有一个命令来计算的东西的力量,我是不知道的?
but that's not doing anything. Is there a command to calculate the power of something that I'm not aware of?
推荐答案
在bash功率运算符是 **
The power operator in bash is **
例如:
echo $((2 ** 4))
16
这篇关于计算在bash电源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文