QuestionQ32

Essential Commands

Which of the following commands replaces every occurrence of bob in the file letter with Bob and writes the output to the file newletter?

  • A sed '/bob/Bob' letter > newletter
  • B sed s/bob/Bob/ letter < newletter
  • C sed 's/bob/Bob' letter > newletter
  • D sed 's/bob/Bob/g' letter > newletter
  • E sed 's/bob, Bob/' letter > newletter
Explanation

In sed, s/bob/Bob/g performs a substitution of bob with Bob globally on each line. Redirecting standard output with > newletter saves the transformed content in newletter.

Community Discussion

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