Bash Scripting - Variables
Identify the error in this script snippet:
export VAR=hello
function test() {
VAR=world
local VAR
echo $VAR
}
test
echo $VARexport VAR=hello
function test() {
VAR=world
local VAR
echo $VAR
}
test
echo $VARlocal VAR must appear before assigning a value to VAR inside the function to make it local.echo $VAR prints empty.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions