Which of the following commands replaces each occurrence of 'bob' in the file letter with 'Bob' and writes the result to the file newletter?
Which of the following commands replaces each occurrence of 'bob' in the file letter with 'Bob' and writes the result to the file newletter?
The correct command to replace each occurrence of 'bob' in the file 'letter' with 'Bob' and write the result to the file 'newletter' is `sed 's/bob/Bob/g' letter > newletter`. The `s/bob/Bob/` part of the command tells `sed` to substitute (replace) 'bob' with 'Bob', and the `g` at the end ensures that this substitution is done globally, i.e., all occurrences in the file are replaced. The `>` symbol is used to redirect the output to the file 'newletter'.
The command that replaces each occurrence of 'bob' in the file `letter` with 'Bob' and writes the result to the file `newletter` is: D. `sed 's/bob/Bob/g' letter > newletter` The `sed` command with the `'s/bob/Bob/g'` expression is used for global substitution, meaning it replaces all occurrences of 'bob' with 'Bob' in the file. The output is then redirected to the file `newletter`.