ITPub博客

首页 > Linux操作系统 > Linux操作系统 > global_variable VS local_variable &functional

global_variable VS local_variable &functional

原创 Linux操作系统 作者:wuxidba 时间:2011-06-12 18:24:56 0 删除 编辑
#!/bin/bash
#Define bash global variable
#This variable is global and can be used anywhere in this bash script
VAR="global variable"
function bash {
#Define bash local variable
#This variable is local to bash function only
local VAR="local variable"
echo $VAR
}
echo $VAR
# call the function
bash
# Note the bash global variable did not change
# "local" is bash reserved word
echo $VAR

NOTE: There is no any ";" at the end of each line

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23895263/viewspace-697715/,如需转载,请注明出处,否则将追究法律责任。

上一篇: Hello world
请登录后发表评论 登录
全部评论

注册时间:2010-05-12

  • 博文量
    64
  • 访问量
    63252