shelll函数求两个输入数字之和

#!/bin/bash
#This is a test of the addition of the program!
function AddFun
{
  read -p "Enter a number:" num1
  read -p "Enter another number:" num2
  echo  $[ $num1 + $num2 ]
}
result=`AddFun`
echo "The Result is :$result"

 上面这段代码主要实现的功能是建立一个函数,通过控制台输入2个数字后,求这两个数字之后并输出结果。这个程序并不是很难,但是新手刚写,真的未必写得出来的。放在这里,只是一个点滴积累,在忘记语法的时候可以有个查看的依据----2016年11月的第一天

posted @ 2016-11-01 17:22  OLIVER_QIN  阅读(1994)  评论(0编辑  收藏  举报