Operational Linux OS Shell Interview Questions & Answers:
a) the value of "san_var" is 10
Output:
root@ubuntu:/home/google# ./test.sh
the value of "san_var" is 10
root@ubuntu:/home/google#
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#
d) san_1 san_2 san_3
Explanation:
All items of an array can be accessed by using ${[*]} or ${[@]}.
Output:
root@ubuntu:/home/google# ./test.sh
san_1 san_2 san_3
root@ubuntu:/home/google#
d) both (a) and (b)
Explanation:
The doller sign ($) is used to access a variable's value, not to define it.
Output:
root@ubuntu:/home/google# ./test.sh
./test.sh: line 3: 10=20: command not found
10
root@ubuntu:/home/google#
a) google
$san_var
"$san_var"
'google'
$san_var
Explanation:
Using double quotes does not affect the substitution of the variable, while single quotes and backslash do.
Output:
root@ubuntu:/home/google# ./test.sh
google
$san_var
"$san_var"
'google'
$san_var
root@ubuntu:/home/google#
8. Which one of the following is not a valid shell variable?
a) _san
b) san_2
c) _san_2
d) 2_san
d) 2_san
Explanation:
The shell variable can contain only letters(a to z or A to Z), numbers(0 to 9), or a underscore character(_) and a variable can not start with a number.
https://InterviewQuestionsAnswers.ORG.