函数功能的使用
[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