脚本函数写法

创建函数的格式,有两种:

function name { commands }

name() { commands }


#!/bin/bash

echo $(uname); #the global Variable
declare num=1000;

uname()
{
echo "test!";
((num++));
return 100;
}
testvar()
{
local num=10;
((num++));#
echo "the local num is:$num" ;

}

uname;
echo $? #the function uname value of returning
echo $num;
testvar;
echo $num;

原文地址:https://www.cnblogs.com/AntonioSu/p/8286958.html