Olete.in
Articles
Mock Tests
🧪 Shell Scripting MCQ Quiz Hub
Shell Scripting Mcq Question Set 3
Choose a topic to test your knowledge and improve your Shell Scripting skills
1. Which of the following is not a type of shell?
The C Shell
The Korn Shell
The Bourne Shell
None of the mentioned
2. Which of the following is true about shell?
A Shell provides you with an interface to the Unix system.
Shell gathers input from you and executes programs based on that input.
Shell is an environment in which we can run our commands, programs, and shell scripts.
All of the above
3. What will be the output of $date?
Yesterday date
Current date
Current date and time
Tomarrow date and time
4. The original Unix shell was written in the mid _______
1960s
1970s
1980s
1990s
5. The original Unix shell was written by _____
Stephen R. Bourne
Stephen R. Korn
Stephen R. C.
Stephen Watson
6. How many types of files are there in Unix?
2
3
4
5
7. Which of the following is true about files?
All data in Unix is organized into files.
All files are organized into directories.
The directories are organized into a tree-like structure called the filesystem.
All of the above
8. Which command is used to list all the files?
ld
lr
ls
lp
9. Which of the following symbol represents the current directory?
Double dot (..)
Dollar dot($.)
Single dot (.)
Hash dot(#.)
10. Which of the following syntax is used for creating files in VI editor?
$# vi filename
$ vi filename
# vi filename
& vi filename
11. The most common file type is ___.
ordinary file
directory file
device file
ordinary file and directory file
12. Each entry of directory file has component(s) namely _____.
filename
inode number
file size
Both a and b
13. _____ and _____ cannot be used in a filename.
/, NULL
$,^
., %
NULL, $
14. How many stream Unix program has?
2
3
4
5
15. What is the associated file descriptor for stdout?
0
1
2
-1
16. The name of a variable can contain ________.
numbers
letters
underscore character
All of the above
17. Unix shell variables will have their names in _____.
Uppercase
Lowercase
First character Uppercase and all other character Lowercase
First character Lowercase and all other character Uppercase
18. Whch of the following is invalid variable names?
VAR_1
_ALI
VAR1
VAR_A!
19. Which of the following command is used to display the environment variables only?
sh
set
env
var
20. How many prompt shell has?
4
2
3
5
21. Which keyword is used to remove the variable?
remove
readonly
unset
delete
22. We cannot use the unset command to unset variables that are marked _______
read
write
readonly
writeonly
23. $# is used to show?
The number of arguments supplied to a script.
The filename of the current script.
The exit status of the last command executed.
The process number of the last background command
24. What is true about array variable in Shell?
Shell supports a different type of variable called an array variable.
array variable can hold multiple values at the same time.
Arrays provide a method of grouping a set of variables
All of the above
25. Which of the following is correct syntax for defining array values?
array_name{index}=value
array_name(index)=value
array_name[index]=value
. [index]array_name=value
26. What is the syntax of array initialization when you are using ksh shell?
array_name[index]=value
set -A array_name value1 value2 ... Valuen
array_name=(value1 ... valuen)
${array_name[index]}=value
27. What is the syntax of array initialization when you are using bash shell?
array_name[index]=value
set -A array_name value1 value2 ... Valuen
array_name=(value1 ... valuen)
${array_name[index]}=value
28. what is the syntax to access array values?
${array_name[index]}
#{array_name[index]}
$${array_name[index]}
$[array_name{index}]
29. A shell variable is capable enough to hold a single value. These variables are called _____
vector variables
scalar variables
array variables
none of the above
30. Which of the following syntax is used to access all the items in an array?
${array_name[*]}
${array_name[@]}
${array_name[$]}
Both A and B
31. Which of the following code is used to print elements in range?
${arr[@]:1:4}
${arr[@]}
${arr[*]}
Both A and C
32. Which of the following code will count Length of in Array?
${#arr[0]}
${#arr}
${#arr[#]}
Both a and b
33. Which of the following is correct code to search in array?
${arr[@]/*[aA]*/}
${arr[#]/*[aA]*/}
${arr[*]/*[aA]*/}
Both A and C
34. Which of the following operator is not supported in Bourne shell?
Arithmetic Operators
Boolean Operators
Character operators
File Test Operators
35. Which external program used by bourne shell to perform simple arithmetic operations?
awk
expr
sum
Both a and b
36. The complete expr and awk expression should be enclosed between _____
()
. " "
' '
< >
37. In relational operator, which keyword is used to represent greater than or equal?
-eq
-gte
-ge
-gt
38. Which of the boolean operator is supported in bourne shell?
and
or
not
All of the above
39. What is the use of str operator in bourne shell?
Checks if str is not the empty string
Checks if the given string operand size is non-zero
Checks if the given string operand size is zero
Checks if the value of two operands are equal or not
40. Which File test operator is used to checks if file has its sticky bit set?
-g
-k
-p
-a
41. What is the used of -x file test operator?
Checks if file is executable
Checks if file has size greater than 0
Checks if file exists
Checks if file has its Set User ID (SUID) bit set
42. What is the use of -z string operator in bourne shell?
Checks if the value of two operands are equal or not
Checks if the given string operand size is zero
Checks if the given string operand size is zero
Checks if the given string operand size is non-zero
43. What is the use of -e file test operator in korn shell?
Checks if file is a directory
Checks if file is an ordinary file as opposed to a directory or special file
Checks if file exists
Checks if file is executable
44. Which of the following loops is not available in shell?
The for loop
The until loop
The select loop
The foreach loop
45. The _______ loop executes the given commands until the given condition remains true.
For loop
While loop
until loop
Both b and c
46. Which of the following statements that are used to control shell loops?
break
continue
Both A and B
None of the above
47. A loop may continue forever if the required condition is not met is known as _______
finite loop
infinite loop
simple loop
definate loop
48. Which of the following statement is used to terminate the execution of the entire loop?
continue
terminate
this
break
49. What is the syntax of break command that can also be used to exit from a nested loop?
break
break loop
break n
break n+i
50. Which of the following statement is supported in unix shell?
case
Switch
switch...case
case...esac
Submit