QuestionQ20

Automation, Orchestration, and Scripting

A systems administrator is making configuration changes and must replace a hostname in a particular file. Which command should the administrator use to perform this task?

  • A cut -d oldhostname /etc/configuration.file | vi newhost.name
  • B sed -i 's/oldhostname/newhostname/' /etc/configuration.file
  • C cat /etc/configuration.file | grep oldhostname > newhost.name
  • D grep oldhostname /etc/configuration.file | awk '{print $1 newhostname}'
Explanation

sed -i 's/oldhostname/newhostname/' /etc/configuration.file substitutes newhostname for oldhostname and writes the change directly to the specified file.

Community Discussion

No comments yet. Be the first to start the discussion!