Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam LFCS topic 1 question 68 discussion

Actual exam question from Linux Foundation's LFCS
Question #: 68
Topic #: 1
[All LFCS Questions]

Which of the following commands replaces each occurrence of 'bob' in the file letter with 'Bob' and writes the result 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
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Strib
9 months, 2 weeks ago
Selected Answer: D
D. sed 's/bob/Bob/g' letter > newletter Explanation: The sed command is a stream editor used for modifying and transforming text. The s/old/new/g syntax is used in sed to substitute the first occurrence or all occurrences of "old" with "new" in a given input. In this case, the command sed 's/bob/Bob/g' letter > newletter is the correct choice. It reads the contents of the file "letter," replaces each occurrence of "bob" (case-sensitive) with "Bob," and then redirects the output to the file "newletter." The "g" at the end of the command is used as a flag to indicate a global replacement, meaning it replaces all occurrences of "bob" on each line of the file. Option D is the correct command for replacing each occurrence of 'bob' with 'Bob' in the file "letter" and writing the result to the file "newletter."
upvoted 2 times
...
rhylos
2 years, 8 months ago
Correct. student@centos ~]$ cat letter bob bob and john [student@centos ~]$ sed 's/bob/Bob/g' letter > newletter [student@centos ~]$ cat newletter Bob Bob and john
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 ...