脚本函数写法

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

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;

 

posted @ 2018-01-15 10:24  suwenyuan  阅读(123)  评论(0编辑  收藏  举报