函数的用法

函数功能的使用
[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 #调用函数,执行这个函数

posted @ 2015-02-01 16:27  大都比2号  阅读(89)  评论(0编辑  收藏  举报