Linux OS Shell Question:
Download Questions PDF

What is the output of this program?

#!/bin/sh
san_function() {
echo "Welcome to the google"
printf "World of Linuxn"
}
unset -f san_function
san_function
exit 0
a) Welcome to the google
b) World of Linux
c) both (a) and (b)
d) nothing will print

Linux Shell Interview Question
Linux Shell Interview Question

Answer:

d) nothing will print
Explanation:
Function definition was deleted before calling the function. command 'unset -f function_name' deletes the function definition.
Output:
root@ubuntu:/home/google# ./test.sh
./test.sh: 6: san_function: not found
root@ubuntu:/home/google#

Download Linux Shell Interview Questions And Answers PDF

Previous QuestionNext Question
Parameters can be passed to a function:
a) by using the parameter variables $1, $2, $3…….
b) by using the environment variables
c) both (a) and (b)
d) none of the mentioned
What is the output of this program?

#!/bin/sh
var="google"
san_function() {
var="Linux"
echo $var
}
san_function
exit 0
a) google
b) Linux
c) command not found
d) none of the mentioned