Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

sed: replace in place

Answer:

Newer version of sed allow you replace a file in place, no more redirection is needed.

# sed -i 's/abc/def/g' test.txt

The above command will replace all "abc" to "def" in the file test.txt

  1. Search and replace string in file using Perl
  2. How to redirect output to more than one place
  3. How to replace a string in a file using Perl
  4. Replace multiple strings using sed
  5. Replace text in vi

One Response to “sed: replace in place”

  1. [...] using sed, Perl can also replace file in place with [...]

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>