exam questions

Exam XK0-004 All Questions

View all questions & answers for the XK0-004 exam

Exam XK0-004 topic 1 question 244 discussion

Actual exam question from CompTIA's XK0-004
Question #: 244
Topic #: 1
[All XK0-004 Questions]

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?

  • A. sed 's|.50|.100|g' serverlist.txt
  • B. sed -g 's|.50|.100|a' serverlist.txt
  • C. sed -i 's|.50|.100|' serverlist.txt
  • D. sed -i 's|.50|.100|g' serverlist.txt
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
J_Dawg
Highly Voted 3 years, 7 months ago
Both C and D would work. Since the match only occurs once on the line, the 'g' is not necessary.
upvoted 5 times
melekhov88
3 years, 5 months ago
I think it needs to be "C". in case of address 10.10.50.50 -> command "D" will convert it into 10.10.100.100
upvoted 5 times
...
...
saci_frosty
Most Recent 2 years, 5 months ago
Selected Answer: A
sed 's/.50/.100/g' serverlist.txt There are 3 instances of .50 to be replaced on the file. Unless of course if it is a typo than it should be D. --i, --in-place [=SUFFIX] Perform edits in-place by overwriting the original file.
upvoted 3 times
...
Tlin
2 years, 6 months ago
The answer is C just confirmed in my lab. A will change the file temporarily. D returns an error.
upvoted 2 times
edwram
2 years, 6 months ago
you are correct C is the answer, retested and saw that you were correct.
upvoted 2 times
...
...
edwram
2 years, 6 months ago
Selected Answer: A
A is correct Replacing all the occurrence of the pattern in a line : The substitute flag /g (global replacement) specifies the sed command to replace all the occurrences of the string in the line. $sed 's/unix/linux/g' geekfile.txt
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago