Which of the following sed commands will replace all instances of the string foo with the string foobar changing the file file1.txt in place?

Which of the following sed commands will replace all instances of the string foo with the string
foobar changing the file file1.txt in place?

Which of the following sed commands will replace all instances of the string foo with the string
foobar changing the file file1.txt in place?

A.
sed ‘s/foo/foobar/g’ filel M

B.
sed ‘s/foo/foobar/g’ filel M > filel M

C.
sed ‘s/foo/foobar/g’ filel M | filel M

D.
seD.i’s/foo/foobar/g’file1.txt

E.
seD.i ‘s/foo/foobar/g’ filel M > filel M

Explanation:
sed called Stream Editor, usually used to search and replace the string pattern in file. Syntax: sed
‘s /whattofind/replacewith/globally’ filename
Example: sed ‘s /cat/dog/g’ test CI will replace all cat occuranee to dog fron test file.



Leave a Reply 1

Your email address will not be published. Required fields are marked *


Mahoni

Mahoni

I think answer should be following;

sed -i ‘s/foo/foobar/g’ file1.txt