Using which of the following control mode commands is the correct way to substitute all occurrences of /dev/sdc with /dev/sdd while editing a file in vi?
Click on the arrows to vote for the correct answer
A. B. C. D.A.
The correct command to substitute all occurrences of /dev/sdc with /dev/sdd while editing a file in vi is option D: :%s//dev/sdc//dev/sdd.
Here's a breakdown of the command and its components:
Option A, :s//dev/sdc//dev/sdd, is incorrect because it omits the delimiter characters and specifies an empty search string. It would result in a syntax error.
Option B, :s//dev/sdc//dev/sdd/g, is correct except that it specifies the global substitution flag (the "g" at the end) unnecessarily. The global flag is implied by the use of the percent sign (%), which specifies that the substitution should be performed on all lines in the file.
Option C, :s//dev/sdc//dev/sdd, is correct except that it only performs the substitution on the current line. Without the global flag (the "g" at the end), it would only substitute the first occurrence on each line.