Linux find and replace within file

Aug 31
0

Linux find and replace within file

Tue, 2010-08-31 15:16 — superuser

To find and replace across a file (or files) or a SQLdump you can do something like the following

sed -i 's/sites\/default/sites\/newsite/g' newsite.sql

Note the forward slashes have been escaped in the above examples

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo].

More information about formatting options