Back OS

Ultra Fast Search and Replace Text Inside A Large File with Sed

WRITTEN BY ON 10 Mar 2014
5,301 VIEWS • SHARES
0 comments

I was trying to replace domain name of WordPress database file, it was 41MB. By using editors, the editors became unresponsive. After some Google search, I discovered sed stream editor. It replaced all the text within a few seconds!

sed also available for Windows. Here a breif intro of sed:

A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline). While in some ways similar to an editor which permits scripted edits (such as ed), sed works by making only one pass over the input(s), and is consequently more efficient. But it is sed's ability to filter text in a pipeline which particularly distinguishes it from other types of editors.
sed 's/olddomain.com/newdomain.com/g' input.sql > output.sql
Join the discussion

Comments will be moderated and rel="nofollow" will be added to all links. You can wrap your coding with [code][/code] to make use of built-in syntax highlighter.