乘上命令行终端UNIX [英] Multiplication on command line terminal UNIX

查看:115
本文介绍了乘上命令行终端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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆