码迷,mamicode.com
首页 > 其他好文 > 详细

函数的用法

时间:2015-02-01 17:22:55      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:

函数功能的使用
[root@teacher lianxi]# vim function.sh
[root@teacher lianxi]# chmod +x function.sh
[root@teacher lianxi]# ./function.sh
please key in first num
10
please key in second num
23
num1 + num2 equal 33
[root@teacher lianxi]# cat function.sh
sum() #定义函数的名称
{
echo "please key in first num"
read num1
echo "please key in second num"
read num2
let num3=$num1+$num2
echo -e "\033[31m $num1 + $num2 equal $num3 \033[0m"

}
sum #调用函数,执行这个函数

函数的用法

标签:

原文地址:http://www.cnblogs.com/blog-acf/p/4265669.html

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