CompTIA Linux+ (XK0-004) — Question 310

A Linux administrator recently changed the IP addresses of all the web servers from 10.10.50.x to 10.10.100.x. The administrator needs to update the serverlist.txt file to reflect the change.
The file contains the following:
10:WebSvr01:10.10.50.21:Main
11:WebSvr02:10.10.50.22:Acconting
12:WebSvr03:10.10.50.23:Intranet
20:NFS01:10.10.20.21:FileServer
30:SMTP01:10.10.30.31:Email
Which of the following commands will change the IP addresses and update the files in place?

Answer options

Correct answer: A

Explanation

Option A is correct because it uses the 's' command in sed to globally replace occurrences of '.50' with '.100' in the file. Option B is incorrect as it uses an invalid flag 'a', which is not recognized in this context. Option C fails to include the global flag 'g', meaning it would only replace the first occurrence of '.50' in each line. Option D, while it has the right syntax for in-place editing, is not needed because the question specifies updating all occurrences, which is correctly handled by option A.