UNIX sed Commands MCQs

By: Prof. Fazal Rehman Shamil

Solved UNIX Commands (sed) MCQs on Redirection and Pipes in operating systems.

The last line is displayed by the command $ sed -n ‘$p’ emp.lst.
(A). False
(B). True
(E). None of these
MCQ Answer: b
To add two spaces before every line in emp.lst which command is used?
(A). sed ‘s / / /’emp.lst
(B). sed ‘s/^/ /’ emp.lst
(C). sed ‘s /$/ /’emp.lst
(D). sed ‘s/$/
(E). None of these
MCQ Answer: b
Substitution can also be performed by sed.
(A). False
(B). True
(E). None of these
MCQ Answer: b
Which of the following command is used for selecting lines containing gupta and agarwal?
(A).sed -n
(B). sed -n ‘/gupta/agarwal/p’ emp.lst
(C). sed ‘/gupta | agarwal’p’ emp.lst
(D). sed -n ‘/gupta/,/agarwal/p’ emp.lst
(E). None of these
MCQ Answer: d
To replace the string Linux with Red hat Linux, which shortcut is offered by sed?
(A). { }
(B). ( )
(C). &
(D). ^^
(E). None of these
MCQ Answer: c
To select lines 3 to 10 from emp.lst, which command is used?
(A). sed -n ‘3,10p’ emp.lst
(B). sed 3,10 emp.lst
(C). sed -n ‘^,10p’ emp.lst
(D). sed -n, 10p
(E). None of these
MCQ Answer: a
To use multiple instructions, which option do we use with sed?
(A). -f
(B). –f and -e
(C). -e
(D). -n
(E). None of these
MCQ Answer: b
___option is used, for suppressing the behavior of ‘p’ command of sed.
(A). -q
(B). -i
(C). -n
(D). -v
(E). None of these
MCQ Answer: c
We use____ with sed for writing the selected lines.
(A). w
(B). n
(C). i
(D). p
(E). None of these
MCQ Answer: a
Which commands is called stream editor?
(A). tr
(B). grep
(C). grep
(D). sed
(E). None of these
MCQ Answer: d
To perform substitution using sed which is the correct syntax?
(A). sed [address]s /expr1/ expr2/ flags
(B). sed [address]s /expr1 expr2
(C). sed [address]s /expr1/ expr2
(D). sed [address]s
(E). None of these
MCQ Answer: a
To take instructions from a file, we use ______ option.
(A). -e
(B). -f
(C). -i
(D). -n
(E). None of these
MCQ Answer: b
To use sed the correct syntax is__________
(A). sed options ‘address action’ file(s)
(B). sed options ‘action’
(C).sed options file(s)
(D). sed ‘action’ file(s)
(E). None of these
MCQ Answer: a
To quit after selecting 3 lines from the file emp.lst which command is used?
(A). sed ‘3q’ emp.lst
(B). sed -i 1-3 emp.lst
(C). sed -n 3 emp.lst
(D). sed -n
(E). None of these
MCQ Answer: a
To get the output as well as printing the selected lines, which command is used with sed?
(A). p
(B). n
(C). q
(D). i
(E). None of these
MCQ Answer: a
To replace | with : globally, which command is used?
(A). sed ‘s/|/:/’ emp.lst
(B). sed ‘/|/:/’ emp.lst
(C). sed ‘s/
(D).sed ‘s/|/:/g’ emp.lst
(E). None of these
MCQ Answer: d
Which of the following command is used to replace the string ‘director’ in first five lines of file emp.lst with ‘manager’?
(A). sed ‘1,5s/director/manager/’ emp.lst
(B). sed ‘1-5s/director/manager/’ emp.lst
(C). sed ‘s/director/manager/’ emp.lst
(D). sed ‘15s
(E). None of these
MCQ Answer: a
As anchoring characters, which characters are used with sed?
(A). $ and ^
(B). ^
(C). %
(D).$
(E). None of these
MCQ Answer: a
Function of the following command will be____
$ sed ‘s/ *|/|/g’ emp.lst
(A). replace * with |
(B). compress multiple spaces
(C). replace / with |
(D). erroneous output
(E). None of these
MCQ Answer: b
Into ____ categories, the basic regular expressions are divided.
(A). 3
(B). 1
(C). 2
(D). 5
(E). None of these
MCQ Answer: a
_____ character is used by interval regular expression
(A). { and }
(B). }
(C). {
(D). ( and )
(E). None of these
MCQ Answer: a
In ___ the pattern should be enclosed for performing context addressing.
(A). double quotes
(B). / /
(C). single quotes
(D). $ $
(E). None of these
MCQ Answer: b

Next Operating System MCQs

Computer Science Repeated MCQs Book Download

Prof. Fazal Rehman Shamil