UNIX sed Commands MCQs

1.The last line is displayed by the command $ sed -n ‘$p’ emp.lst.
(A). False
(B). True
(E). None of these
MCQ Answer: b
2. 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
3. Substitution can also be performed by sed.
(A). False
(B). True
(E). None of these
MCQ Answer: b
4. 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
5. 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
6. 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
7. 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
8. ___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
9. We use____ with sed for writing the selected lines.
(A). w
(B). n
(C). i
(D). p
(E). None of these
MCQ Answer: a
10. Which commands is called stream editor?
(A). tr
(B). grep
(C). grep
(D). sed
(E). None of these
MCQ Answer: d
11. 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
12. To take instructions from a file, we use ______ option.
(A). -e
(B). -f
(C). -i
(D). -n
(E). None of these
MCQ Answer: b
13. 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
14. 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
15. 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
16. 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
17. 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
18. As anchoring characters, which characters are used with sed?
(A). $ and ^
(B). ^
(C). %
(D).$
(E). None of these
MCQ Answer: a
19. 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
20. Into ____ categories, the basic regular expressions are divided.
(A). 3
(B). 1
(C). 2
(D). 5
(E). None of these
MCQ Answer: a
21. _____ character is used by interval regular expression
(A). { and }
(B). }
(C). {
(D). ( and )
(E). None of these
MCQ Answer: a
22. 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