方法一: 使用全局变量
- g_result=""  
 -   
 - function testFunc()  
 - {  
 -     g_result='local value'  
 - }  
 -   
 - testFunc  
 - echo $g_result  
 
方法二: 把shell函数作为子程序调用,将其结果写到子程序的标准输出- function testFunc()  
 - {  
 -     local_result='local value'  
 -     echo $local_result  
 - }  
 -   
 - result=$(testFunc)  
 - echo $result  
 
看到一篇关于函数返回值的好文章,分享一下: http://www.linuxjournal.com/content/return-values-bash-functions 
	posted on 2015-09-21 10:20 
xzc 阅读(4463) 
评论(2)  编辑  收藏  所属分类: 
linux/unix