LPIC-1 Exam 101 (Linux Administrator) — Question 37

Which of the following commands replaces each occurrence of 'bob' in the file letter with 'Bob' and writes the result to the file newletter?

Answer options

Correct answer: D

Explanation

The correct answer is D because it uses the 'g' flag to globally replace all occurrences of 'bob' with 'Bob'. Option A is incorrect as it uses an invalid syntax, option B mistakenly uses input redirection instead of output redirection, option C does not include the 'g' for global replacement, and option E has a syntax error due to the misplaced comma.