vi function11.sh
#!/bin/bash
text="global variable"
#函数中使用的局部变量和全局变量的名字相同
use_local_var_fun()
{
local text="local variable"
echo "In function use_local_var_fun"
echo $text
}
#输出函数use_local_var_fun内部的局部变量
echo "Execute the function use_local_var_fun"
use_local_var_fun
#输出函数use_local_var_fun外的全局变量值
echo "Out of function use_local_var_fun"
echo $text
exit 0
./function11.sh
Execute the function use_local_var_fun
In function use_local_var_fun
local variable
Out of function use_local_var_fun
global variable