nerdexam
CompTIA

XK0-005 · Question #875

A server's IP address has been changed from 10.115.6.5 to 10.116.6.5. Because of this change, the application server needs to be reconfigured. Which of the following commands will allow the systems…

The correct answer is C. sed -i 's/10.115.6.5/10.116.6.5/g' /etc/app.cfg. The sed (Stream Editor) command is commonly used for text replacement in files. -i - Edits the file in place (modifies /etc/app.cfg directly). s/old/new/g - Replaces all occurrences (g = globally) of 10.115.6.5 with 10.116.6.5. /etc/app.cfg - Specifies the file to modify.

System Management

Question

A server’s IP address has been changed from 10.115.6.5 to 10.116.6.5. Because of this change, the application server needs to be reconfigured. Which of the following commands will allow the systems engineer to change the IP address in the /etc/app.cfg file quickly?

Options

  • Aawk '{rep(/10.115.6.5/"10.116.6.5")}" /etc/app.cfg
  • Bperl -i 's/10.115.6.5/10.116.6.5/g" /etc/app.cfg
  • Csed -i 's/10.115.6.5/10.116.6.5/g' /etc/app.cfg
  • Dpython -c "import sys;print file.replace('10.115.6.5','10.116.6.5')" <

How the community answered

(16 responses)
  • A
    6% (1)
  • C
    81% (13)
  • D
    13% (2)

Explanation

The sed (Stream Editor) command is commonly used for text replacement in files. -i - Edits the file in place (modifies /etc/app.cfg directly). s/old/new/g - Replaces all occurrences (g = globally) of 10.115.6.5 with 10.116.6.5. /etc/app.cfg - Specifies the file to modify.

Topics

#sed#text manipulation#configuration files#command line

Community Discussion

No community discussion yet for this question.

Full XK0-005 Practice