PrepAway - Latest Free Exam Questions & Answers

Which of the following commands will you use?

You work as a Network Administrator for Net Perfect Inc. The company has a Linux-based
network.
By using the VI utility, you have created a document that has 100 lines. You want to replace all the
occurrences of “net” with “Net” in the first 50 lines of the document. Which of the following
commands will you use?

PrepAway - Latest Free Exam Questions & Answers

A.
:1,$ s/net/Net/g

B.
:1,100 s/net/Net/g

C.
:1,50 s/net/Net/g

D.
:s/net/Net/g

Explanation:

In order to replace all the occurrences of “net” with “Net” in the first fifty lines of the file, you will
have to execute the following command: :1,50 s/net/Net/g
This command is issued in the command mode of the VI utility. 1,50 defines the initial and final line
numbers of the current document where the command will execute. The s/ switch with the
net/Net/g option will globally replace all the occurrences of “net” with “Net”.
Answer option A is incorrect. This command will replace “net” with “Net” all over the current
document.
Answer option B is incorrect. Since this command executes on the first 100 lines of a document, it
will replace “net” with “Net” in all the 100 lines of the current document.
Answer option D is incorrect. This command will replace “net” with “Net” in the current line of the
current document.


Leave a Reply