我目前正在尝试在Unix中添加附加命令,并提出了以下代码:
#! /bin/bash
#! Add - adds two given numbers together and displays the result
"$num1" = $1
"$num2" = $2
echo "Enter two numbers"
read num1 num2
sum=$(“$num1” + “$num2”)
echo "The sum is = $sum"
但是,这不起作用。
((...))
是执行算术的方法,而不是单个括号,并且您在那不需要引号试试:
sum=$((num1+num2))
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句