方法一: 使用全局变量
[html] view plaincopy在CODE上查看代码片派生到我的代码片
g_result=""
function testFunc()
{
g_result='local value'
}
testFunc
echo $g_result
方法二: 把shell函数作为子程序调用,将其结果写到子程序的标准输出
[html] view plaincopy在CODE上查看代码片派生到我的代码片
function testFunc()
{
local_result='local value'
echo $local_result
}
result=$(testFunc)
echo $result
原文链接:www.blogjava.net/xzclog/archive/2015/09/21/427407.html