求两数之和,funWithReturn()函数中间是函数体,输出的$?是函数运算的结果
#!/bin/bash
#20201203.sh
funWithReturn(){
echo "这个函数会对输入的两个数字进行相加运算。。。"
echo "输入第一个数字:"
read anum
echo "输入第二个数字:"
read anothernum
echo "两个数字分别为$anum 和 $anothernum!"
return $(($anum+$anothernum))
}
#funWithReturn
#echo "输入的两个数字之和为$? !"
##2020120302.sh调用20201203.sh
#!/bin/bash
# 2020120302.sh
source /../2020120302.sh
# 或者 . /../2020120302.sh
funWithReturn
echo "输入的两个数字之和为$? !"