Bash Scripting - Functions
Find the error in this script:
print_msg() {
echo "Message: $msg"
}
print_msg
msg="Hello"print_msg() {
echo "Message: $msg"
}
print_msg
msg="Hello"msg is defined after the function call, so it is not available when the function executes.msg is not defined before calling print_msg, so $msg inside the function is unset.msg must be defined before the function call to be accessible.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions