Unix Shell Operators MCQs
Shell Operators MCQs : This section focuses on "Operator" in Shell Progamming in Unix. These Multiple Choice Questions (MCQ) should be practiced to improve the unix skills required for various interviews (campus interviews, walk-in interviews, company interviews), placements, entrance exams and other competitive examinations.
1. Which of the following operator is not supported in Bourne shell?
A. Arithmetic Operators
B. Boolean Operators
C. Character operators
D. File Test Operators
View Answer
Ans : C
Explanation: character operator is not in the Bourne shell, instead of the character operator, there is an operator called a string operator.
2. Which external program used by bourne shell to perform simple arithmetic operations?
A. awk
B. expr
C. sum
D. Both A and B
View Answer
Ans : D
Explanation: Bourne shell do not have any mechanism to perform simple arithmetic operations but it uses external programs, either awk or expr.
3. The complete expr and awk expression should be enclosed between ___________.
A. ()
B. " "
C. ' '
D. < >
View Answer
Ans : C
Explanation: The complete expression should be enclosed between , called the backtick.
4. In relational operator, which keyword is used to represent greater than or equal?
A. -eq
B. -gte
C. -ge
D. -gt
View Answer
Ans : C
Explanation: -ge keyword is used to represent greater than or equal.
5. Which of the boolean operator is supported in bourne shell?
A. and
B. or
C. not
D. All of the above
View Answer
Ans : D
Explanation: All the above operators are supported by the Bourne Shell.
6. What is the use of str operator in bourne shell?
A. Checks if str is not the empty string
B. Checks if the given string operand size is non-zero
C. Checks if the given string operand size is zero
D. Checks if the value of two operands are equal or not
View Answer
Ans : A
Explanation: str : Checks if str is not the empty string and if it is empty, then it returns false.
7. Which File test operator is used to checks if file has its sticky bit set?
A. -g
B. -k
C. -p
D. -a
View Answer
Ans : B
Explanation: -k file : Checks if file has its sticky bit set; if yes, then the condition becomes true.
8. What is the used of -x file test operator?
A. Checks if file is executable
B. Checks if file has size greater than 0
C. Checks if file exists
D. Checks if file has its Set User ID (SUID) bit set
View Answer
Ans : A
Explanation: -x file : Checks if file is executable; if yes, then the condition becomes true.
9. What is the use of -z string operator in bourne shell?
A. Checks if the value of two operands are equal or not
B. Checks if the given string operand size is zero
C. Checks if str is not the empty string
D. Checks if the given string operand size is non-zero
View Answer
Ans : B
Explanation: -z : Checks if the given string operand size is zero; if it is zero length, then it returns true.
10. What is the use of -e file test operator in korn shell?
A. Checks if file is a directory
B. Checks if file is an ordinary file as opposed to a directory or special file
C. Checks if file exists
D. Checks if file is executable
View Answer
Ans : C
Explanation: -e : Checks if file exists
Discussion