1 echo -e "Input your operate system:/c"
2 read answer;
3
4 function func
5 {
6 echo "Function start>>>>>>"
7 if [ "$answer" != "`uname`" ]
8 then
9 echo $answer
10 return "1"
11 else
12 echo $answer
13 return "0"
14 fi
15 }
16 ret=`func`
17 echo "*** $ret ***"
想要获得一个函数的执行结果,可将func命令的结果赋给一个变量ret,注意,func应当用反引号引起来,表示命令的执行.