Hey, we started the Linuxdoc.org blog. You want to write a guest post about your favorite Linux related topic? Just send us a mail.The Linux community would appreciate it.

I need to update several files with a particular extension within a directory. A term should be replaced by another one. It is important that even files in subdirectories are inculuded in the changing process. How can i manage to achieve that using sed? Can anyone help?

asked 17 May '11, 05:00

pipe's gravatar image

pipe
21224
accept rate: 0%


You can combine find and sed to search and replace through multiple files:

find . -name "*.html" -type f -exec sed -i -e "s/SearchTerm/ReplaceTerm/g" {} \;
link

answered 17 May '11, 05:18

paul's gravatar image

paul
863
accept rate: 16%

edited 17 May '11, 05:19

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×8
×1
×1

Asked: 17 May '11, 05:00

Seen: 2,900 times

Last updated: 17 May '11, 05:19

we use OSQA