乘上命令行终端UNIX [英] Multiplication on command line terminal UNIX
问题描述
我使用串行终端提供投入我们的实验室实验。
I'm using a serial terminal to provide input into our lab experiment.
我发现的是,使用回声5X5刚返回的5X5的字符串。
I found is that using echo "5X5" just returns a string of "5X5".
有没有执行乘法运算指令?
Is there a command to execute a multiplication operation?
推荐答案
是的,你可以使用的 bash中内置的算术展开 $(())
做一些简单的数学
Yes, you can use bash's built-in Arithmetic Expansion $(( ))
to do some simple maths
$ echo "$((5 * 5))"
25
检查<一个href=\"https://www.gnu.org/software/bash/manual/html_node/Shell-Arithmetic.html#Shell-Arithmetic\">Shell在Bash参考手册运算部分运营商的完整列表。
Check the Shell Arithmetic section in the Bash Reference Manual for a complete list of operators.
有关完整起见,其他指出的那样,如果你需要任意precision, BC
或 DC
效果会更好。
For sake of completeness, as other pointed out, if you need arbitrary precision, bc
or dc
would be better.
这篇关于乘上命令行终端UNIX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!