You have created a really long letter and after you are done you notice that you used the name “Bob” many times but you forgot to capitalize it in many instances. Which command would replace “bob” with “Bob” in all instances and generate a new letter for printing?
A.
sed ‘s/bob/Bob’ letter > newletter
B.
sed ‘/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:
sed is called the stream editor command, which is used to find and replace the string pattern.Example:
#sed ‘s/cat/dog/’ testfile >testfilel: Which replace the cat to dog from testfile and redirect the output into testfi lei file.
What is the ‘g’ meant to be doing in the answer D?
Sed command
—————————————
/g – Global replacement
Most Unix utilities work on files, reading a line at a time. Sed, by default, is the same way. If you tell it to change a word, it will only change the first occurrence of the word on a line. You may want to make the change on every word on the line instead of the first.
Sorry Tom, but I think you are wrong, that decided to study in test questions.
You probably should read some books and work for a while in GNU/Linux systems…
It’s good that you ask questions, but I think that this is not the right way.
Shut up, Alukardd.