Linux OS Shell Question:
Download Questions PDF

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

Linux Shell Interview Question
Linux Shell Interview Question

Answer:

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#

Download Linux Shell Interview Questions And Answers PDF

Previous QuestionNext Question
What is the output of this program?

#!/bin/bash
var[1]=san_1
var[2]=san_2
var[3]=san_3
echo ${var[*]}
exit 0
a) san_1
b) san_2
c) san_3
d) san_1 san_2 san_3
What is the output of this program?

#!/bin/bash
san_var=10
echo "the value of "san_var" is $san_var"
exit 0
a) the value of "san_var" is 10
b) the value of is 10
c) the value of san_var is $san_var
d) the value of "san_var" is $san_var