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.
a) read
a) This is the first function
This is the second function
This is the third function
Output:
root@ubuntu:/home/google# ./test.sh
This is the first function
This is the second function
This is the third function
root@ubuntu:/home/google#
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#
c) This is the first function
This is the second function
b) Linux
Explanation:
If local variable name is same as the global variable, it overlays the variable, but only within the function.
Output:
root@ubuntu:/home/google# ./test.sh
Linux
root@ubuntu:/home/google#
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#
a) by using the parameter variables $1, $2, $3.
a) to define a variable within a function for its local scope
c) both (a) and (b)
Explanation:
'declare -F' provides just the name of the functions and 'declare -f' provides their definitions also.
c) one character
23. * Specifies:
a) one or more character
b) zero or more charecter
c) nothing
d) None of the above
b) zero or more charecter
b) exit status of the last command executed
c) PID of the shell running the script
d) command 2> /dev/null
b) Write data to the physical device sda
b) echo foo >> /tmp/bar