nerdexam
LPI

101-400 · Question #205

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

The correct answer is D. sed -i 's/foo/foobar/g' file1.txt. See the full explanation below for the reasoning.

Question

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

Options

  • Ased 's/foo/foobar/g' file1.txt
  • Bsed 's/foo/foobar/g' file1.txt > file1.txt
  • Csed 's/foo/foobar/g' file1.txt | file1.txt
  • Dsed -i 's/foo/foobar/g' file1.txt
  • Esed -i 's/foo/foobar/g' file1.txt >file1.txt

How the community answered

(28 responses)
  • A
    4% (1)
  • B
    11% (3)
  • C
    4% (1)
  • D
    79% (22)
  • E
    4% (1)

Community Discussion

No community discussion yet for this question.

Full 101-400 Practice