Linux Shell

  Home  Operating System Linux  Linux Shell


“Linux OS Shell frequently Asked Questions by expert members with experience in Linux Shell. These questions and answers will help you strengthen your technical skills, prepare for the new job test and quickly revise the concepts”



53 Linux Shell Questions And Answers

47⟩ 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

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#

 142 views

48⟩ What is the output of this program? #!/bin/sh echo "Just call the function" san_function san_function() { echo "This is a function" } exit 0 a) only first string will print without any error b) only second string will print without any error c) both strings will print d) none of the mentioned

d) none of the mentioned

Explanation:

Function must be defined prior to call. Hence only first string will print and program will generate an error also.

Output:

root@ubuntu:/home/globalguideline# ./test.sh

Just call the function

./test.sh: 3: san_function: not found

root@ubuntu:/home/globalguideline#

 127 views

52⟩ What is the output of this program? #!/bin/bash san_var=hello readonly san_var san_var=hi echo $san_var exit 0 a) hello b) hi c) nothing will print d) none of the mentioned

a) hello

Explanation:

After the execution of the 'readonly' command, shell will not provide the permission to overwrite the value stored in variable 'san_var'.

Output:

root@ubuntu:/home/google# ./test.sh

./test.sh: line 4: san_var: readonly variable

hello

root@ubuntu:/home/google#

 122 views