0
我知道这是基本问题,但我无法在unix中编写简单的添加程序。我使用的cygwin写的shell脚本我的脚本是这样的如何在unix中编写addtion程序
#!/bin/sh
echo "enter the first number"
read a
echo "enter the seconf number"
read b
echo [$a + $b]
我知道这是基本问题,但我无法在unix中编写简单的添加程序。我使用的cygwin写的shell脚本我的脚本是这样的如何在unix中编写addtion程序
#!/bin/sh
echo "enter the first number"
read a
echo "enter the seconf number"
read b
echo [$a + $b]
把两个数相加,你可以这样做:
let c = $a + $b
echo $c
阅读,你可以这样做:
read -p "Enter the first number" a
read -p "Enter the second number" b
#!/bin/sh
echo "enter the first number"
read a
echo "enter the seconf number"
read b
echo $(($a+$b))
[文档参考](http://www.gnu.org/software/bash/manual/bashref.html#Arithmetic-Expansion) –