var1="global var" test() { local var2="local var" echo $var2 } Echo $ var1 test Echo $ var2 test2 () { Echo $ var2 }