码迷,mamicode.com
首页 > 系统相关 > 详细

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

时间:2016-11-01 19:13:24      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:test   2016年   ash   result   bash   not   数字   实现   shel   

#!/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月的第一天

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

标签:test   2016年   ash   result   bash   not   数字   实现   shel   

原文地址:http://www.cnblogs.com/OliverQin/p/6020223.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!