This set of Unix Multiple Choice Questions & Answers (MCQs) focuses on “Handling Multiple Files and Buffers”.
1. Which of the following command is used for switching files?
a) :e
b) e!
c) !e
d) !r
View Answer
Explanation: We can switch between multiple files without quitting the vi editor. For example, while working with one file, we can switch to another by using the following command,
:e file02 // switches to file02
2. For returning back to the original file after switching we can use:
a) :e!
b) ctrl-^
c) :e#
d) ctrl-^ and :e#
View Answer
Explanation: We can switch between multiple files without quitting the vi editor. For this purpose, :e command is used. For returning back to the original file, we can use one of the following commands:
[Ctrl-^] //toggles between previous and current file :e# //same
3. When multiple filenames are used with vi, we can switch to next file using ___ command.
a) new
b) :n
c) :rew
d) :prev
View Answer
Explanation: When vi editor is used with multiple filenames, it loads the first file. We can switch to next file using :n command.
4. We can move back to the previous file using ____ command.
a) new
b) :n
c) :rew
d) :prev
View Answer
Explanation: When vi editor is used with multiple filenames, it loads the first file. We can switch to next file using :n command. In this manner, we can reach to the last file. At any stage, we can move back to the first file using :rew command.
5. :r !date inserts the output of date command in our file.
a) True
b) False
View Answer
Explanation: We can also insert the output of any command in our file using :r command.
6. To split the screen into multiple windows, we can use ____ command.
a) :sp
b) :new
c) :n
d) :r
View Answer
Explanation: We can also split our screen into multiple windows using :sp command. The window can be empty or it can contain a file, even a copy of the same file.
7. To create a new window, ____ can be used.
a) :sp
b) :new
c) :n
d) :r
View Answer
Explanation: We can also create an empty window which will not be associated with any file. For this purpose, :new command is used. Now we can move between these windows using ctrl-w.
8. To remove all other windows except the current one, which of the following command is used?
a) :on
b) :new
c) :n
d) :r
View Answer
Explanation: To make the current window the only window on the screen and close all other windows use :on command. We can also kill the current window using :q.
9. vi editor has ____ named buffers.
a) 2
b) 4
c) 26
d) 5
View Answer
Explanation: vi editor stores the deleted text in an unnamed buffer. But this suffers some limitations. i.e. we can use only one buffer at one time. So vi uses 26 special named buffers which are named after the letters of the alphabet. For example,
“a4yy // yanks 4 lines into buffer a
10. To restore a number of recent deletions, numbered buffers are used.
a) True
b) False
View Answer
Explanation: We often need to restore a number of recent deletions. Vi editor makes it possible to restore up to recent nine complete line deletions using its numbered buffers. For example,
“1p // restores most recent deletion
11. For restoring the contents of numbered buffers efficiently, ___ command is used.
a) .
b) $
c) :nb
d) :q
View Answer
Explanation: vi offers the dot command to restore the contents of any buffer efficiently. Every time this command is pressed, it steps through the buffer set to restore the contents of the next buffer.
12. The technique of restoring line deletions from numbered buffers is applicable only to entire lines.
a) True
b) False
View Answer
Explanation: The technique of restoring line deletions from numbered buffers is applicable only to entire lines. For example, we can’t restore five words deleted with 5dw unless it was the last editing action performed.
13. vi used ___ to enter control characters.
a) ctrl-w
b) ctrl-v
c) ctrl-d
d) esc
View Answer
Explanation: In vi, some characters are directly enterable, but a control character has to be preceded by another control character for it to be interpreted properly. Vi used ctrl-v to precede any control character.
14. To append contents of buffer to file01, we can use __________
a) : w >> file01
b) :r > file01
c) :w > file01
d) :r >> file01
View Answer
Explanation: The command :w >> file01 will append the contents of buffer to the file specified.
15. Which of the following is an invalid command?
a) :r file01
b) :e file01
c) :e#
d) :w # file01
View Answer
Explanation: : r file01 will read the contents of file01 below the current line. :e file01 will stop editing the current file and will edit file01. Similarly, :e# returns to editing most recently edited file.
Sanfoundry Global Education & Learning Series – Unix.
To practice all areas of Unix, here is complete set of 1000+ Multiple Choice Questions and Answers.
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]
- Practice MCA MCQs
- Check Computer Science Books
- Check MCA Books
- Practice Computer Science MCQs
- Check Unix Books