Interviewer And Interviewee Guide

Linux OS Shell Interview Question:

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

Submitted by: Murtaza
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#
Submitted by: Murtaza

Read Online Linux OS Shell Job Interview Questions And Answers
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.