Explore topic-wise MCQs in Unix.

This section includes 12 Mcqs, each offering curated multiple-choice questions to sharpen your Unix knowledge and support exam preparation. Choose a topic below to get started.

1.

To write selected lines, ____ is used with sed.

A. i
B. n
C. w
D. p
Answer» D. p
2.

To select lines containing gupta and agarwal, which command will be used?

A. sed -n ‘/gupta/,/agarwal/p’ emp.lst
B. sed -n ‘/gupta/agarwal/p’ emp.lst
C. sed ‘/gupta | agarwal’p’ emp.lst
D. sed -n
Answer» B. sed -n ‘/gupta/agarwal/p’ emp.lst
3.

To perform context addressing, we have to enclose the pattern in ____

A. double quotes
B. single quotes
C. / /
D. $ $
Answer» D. $ $
4.

____ option is used for taking instructions from a file.

A. -f
B. -e
C. -i
D. -n
Answer» B. -e
5.

Which option is used with sed for using multiple instructions?

A. -f
B. -n
C. -e
D. –f and -e
Answer» E.
6.

Consider the following commands. The output of both commands will be the same.

A. True
B. FalseView Answer
Answer» B. FalseView Answer
7.

The command $ sed -n ‘$p’ emp.lst will display the last line.

A. True
B. False
Answer» B. False
8.

To suppress the behavior of ‘p’ command of sed, we use ____ option.

A. -q
B. -n
C. -i
D. -v
Answer» C. -i
9.

Which of the following command is used with sed for outputting as well as printing the selected lines?

A. q
B. n
C. p
D. i
Answer» D. i
10.

Which one of the following command will be used for quitting after selecting 3 lines from file emp.lst?

A. sed -n 3 emp.lst
B. sed -i 1-3 emp.lst
C. sed ‘3q’ emp.lst
D. sed -n
Answer» D. sed -n
11.

What is the correct syntax for using sed?

A. sed options file(s)
B. sed options ‘action’
C. sed options ‘address action’ file(s)
D. sed ‘action’ file(s)
Answer» D. sed ‘action’ file(s)
12.

Which of the following commands is known as stream editor?

A. sed
B. grep
C. grep
D. tr
Answer» B. grep