<?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/"
		>
<channel>
	<title>Comments on: Recursively Search and Replace Terms in Multiple Files with grep, xargs and sed</title>
	<atom:link href="http://www.64bitjungle.com/ubuntu/recursively-search-and-replace-terms-in-multiple-files-with-grep-xargs-and-sed/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.64bitjungle.com/ubuntu/recursively-search-and-replace-terms-in-multiple-files-with-grep-xargs-and-sed/</link>
	<description>Linux and Programming Tips and Tutorials, Technology and Rants from the Jungle</description>
	<lastBuildDate>Mon, 23 Jan 2012 18:24:20 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Jon Jennings</title>
		<link>http://www.64bitjungle.com/ubuntu/recursively-search-and-replace-terms-in-multiple-files-with-grep-xargs-and-sed/comment-page-1/#comment-18588</link>
		<dc:creator>Jon Jennings</dc:creator>
		<pubDate>Mon, 30 Aug 2010 20:36:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.64bitjungle.com/?p=282#comment-18588</guid>
		<description>Thanks for this - it was really interesting &amp; I learnt about xargs, which I&#039;d never had to fiddle with before.

I suspect my search/rename task might have been beyond the capabilities of this combination of commands - or at least it was beyond the capabilities of me! I was looking to replace HTML quote characters (&#039;) with the literal &#039; symbol throughout files in a hierarchy of directories. This caused me NO END of issues. It seemed the major problems came from the fact that my filenames had both whitespace and literal quotes in them - which cause issues for xargs. The literal quote I was using in my sed string might have been an issue as well, but I think that escaping that made it OK.

I fussed around for half an hour trying to find a combination of escape characters and command line arguments that would make things work but eventually I gave up and had to go looking for a more dummy-friendly solution. I found a GUI program called regexxer that was excellent - well worth checking out for people who can&#039;t get the command-line solution to perform for them.</description>
		<content:encoded><![CDATA[<p>Thanks for this &#8211; it was really interesting &amp; I learnt about xargs, which I&#8217;d never had to fiddle with before.</p>
<p>I suspect my search/rename task might have been beyond the capabilities of this combination of commands &#8211; or at least it was beyond the capabilities of me! I was looking to replace HTML quote characters (&#39;) with the literal &#8216; symbol throughout files in a hierarchy of directories. This caused me NO END of issues. It seemed the major problems came from the fact that my filenames had both whitespace and literal quotes in them &#8211; which cause issues for xargs. The literal quote I was using in my sed string might have been an issue as well, but I think that escaping that made it OK.</p>
<p>I fussed around for half an hour trying to find a combination of escape characters and command line arguments that would make things work but eventually I gave up and had to go looking for a more dummy-friendly solution. I found a GUI program called regexxer that was excellent &#8211; well worth checking out for people who can&#8217;t get the command-line solution to perform for them.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DavidJB.com &#187; Blog &#187; Find and replace across files &#8211; Linux command line</title>
		<link>http://www.64bitjungle.com/ubuntu/recursively-search-and-replace-terms-in-multiple-files-with-grep-xargs-and-sed/comment-page-1/#comment-14393</link>
		<dc:creator>DavidJB.com &#187; Blog &#187; Find and replace across files &#8211; Linux command line</dc:creator>
		<pubDate>Wed, 28 Apr 2010 15:45:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.64bitjungle.com/?p=282#comment-14393</guid>
		<description>[...] post concerns finding and replacing terms across multiple files via a simple command.  Thanks to this great blog post, it all comes down to one single line.  I had found a previously-useful line of code, but the [...]</description>
		<content:encoded><![CDATA[<p>[...] post concerns finding and replacing terms across multiple files via a simple command.  Thanks to this great blog post, it all comes down to one single line.  I had found a previously-useful line of code, but the [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hodge</title>
		<link>http://www.64bitjungle.com/ubuntu/recursively-search-and-replace-terms-in-multiple-files-with-grep-xargs-and-sed/comment-page-1/#comment-8006</link>
		<dc:creator>Hodge</dc:creator>
		<pubDate>Fri, 13 Nov 2009 02:27:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.64bitjungle.com/?p=282#comment-8006</guid>
		<description>Hi Dave,

No real reason other than I like to use grep :)

That&#039;s one of many great things about *NIX systems - there is always more than one way to solve a problem.

Thanks for your suggestion.</description>
		<content:encoded><![CDATA[<p>Hi Dave,</p>
<p>No real reason other than I like to use grep <img src='http://www.64bitjungle.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>That&#8217;s one of many great things about *NIX systems &#8211; there is always more than one way to solve a problem.</p>
<p>Thanks for your suggestion.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Casserly</title>
		<link>http://www.64bitjungle.com/ubuntu/recursively-search-and-replace-terms-in-multiple-files-with-grep-xargs-and-sed/comment-page-1/#comment-7973</link>
		<dc:creator>Dave Casserly</dc:creator>
		<pubDate>Thu, 12 Nov 2009 17:43:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.64bitjungle.com/?p=282#comment-7973</guid>
		<description>Instead of 

grep -lr -e &#039;&#039; * &#124; xargs sed -i &#039;s///g&#039;

Why not:

find -type f &#124; xargs sed -i &#039;s///g&#039;

This saves both grep and sed parsing the file. Pass all files to sed, and let it parse it and replace.</description>
		<content:encoded><![CDATA[<p>Instead of </p>
<p>grep -lr -e &#8221; * | xargs sed -i &#8216;s///g&#8217;</p>
<p>Why not:</p>
<p>find -type f | xargs sed -i &#8216;s///g&#8217;</p>
<p>This saves both grep and sed parsing the file. Pass all files to sed, and let it parse it and replace.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Barry de Graaff</title>
		<link>http://www.64bitjungle.com/ubuntu/recursively-search-and-replace-terms-in-multiple-files-with-grep-xargs-and-sed/comment-page-1/#comment-6854</link>
		<dc:creator>Barry de Graaff</dc:creator>
		<pubDate>Fri, 09 Oct 2009 14:54:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.64bitjungle.com/?p=282#comment-6854</guid>
		<description>With all the knowledge above I created a script that asks you for input and then find and replace recursive in files. It will ask for a final confirmation- and shows the files to be changed.

This one is meant to be integrated in Thunar file manager. But will also work on any other machine that has a desktop environment installed.

http://www.barrydegraaff.tk/files/Linux/scripts/thunar_scripts/search_and_replace.sh

usage:
chmod +x search_and_replace.sh
search_and_replace.sh /path/to/folder

Requires zenity, gxmessage, xargs, grep and sed installed.

I consider myself a bash newbie, so any enhancements are welcome, please notify me at 
http://www.barrydegraaff.tk/index.php?page=_content/contact.html

Happy coding!

Barry</description>
		<content:encoded><![CDATA[<p>With all the knowledge above I created a script that asks you for input and then find and replace recursive in files. It will ask for a final confirmation- and shows the files to be changed.</p>
<p>This one is meant to be integrated in Thunar file manager. But will also work on any other machine that has a desktop environment installed.</p>
<p><a href="http://www.barrydegraaff.tk/files/Linux/scripts/thunar_scripts/search_and_replace.sh" rel="nofollow">http://www.barrydegraaff.tk/files/Linux/scripts/thunar_scripts/search_and_replace.sh</a></p>
<p>usage:<br />
chmod +x search_and_replace.sh<br />
search_and_replace.sh /path/to/folder</p>
<p>Requires zenity, gxmessage, xargs, grep and sed installed.</p>
<p>I consider myself a bash newbie, so any enhancements are welcome, please notify me at<br />
<a href="http://www.barrydegraaff.tk/index.php?page=_content/contact.html" rel="nofollow">http://www.barrydegraaff.tk/index.php?page=_content/contact.html</a></p>
<p>Happy coding!</p>
<p>Barry</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kirlich</title>
		<link>http://www.64bitjungle.com/ubuntu/recursively-search-and-replace-terms-in-multiple-files-with-grep-xargs-and-sed/comment-page-1/#comment-4685</link>
		<dc:creator>kirlich</dc:creator>
		<pubDate>Sat, 11 Jul 2009 20:15:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.64bitjungle.com/?p=282#comment-4685</guid>
		<description>@joe

The character you put after &#039;s&#039; (s being substitute command) determines delimiter you want to use. So you can always specify delimiter that is not contained in your search string to avoid errors, and provide better readability compared to escaping forward slashes. In your case to search for http://www.example.com/oldpage.html and replace it with http://www.example.com/newpage.html you could use &#039;_&#039; as separator:

sed &#039;s_http://www.example.com/oldpage.html_http://www.example.com/newpage.html_g&#039;</description>
		<content:encoded><![CDATA[<p>@joe</p>
<p>The character you put after &#8216;s&#8217; (s being substitute command) determines delimiter you want to use. So you can always specify delimiter that is not contained in your search string to avoid errors, and provide better readability compared to escaping forward slashes. In your case to search for <a href="http://www.example.com/oldpage.html" rel="nofollow">http://www.example.com/oldpage.html</a> and replace it with <a href="http://www.example.com/newpage.html" rel="nofollow">http://www.example.com/newpage.html</a> you could use &#8216;_&#8217; as separator:</p>
<p>sed &#8216;s_http://www.example.com/oldpage.html_http://www.example.com/newpage.html_g&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jordan Garn</title>
		<link>http://www.64bitjungle.com/ubuntu/recursively-search-and-replace-terms-in-multiple-files-with-grep-xargs-and-sed/comment-page-1/#comment-4565</link>
		<dc:creator>Jordan Garn</dc:creator>
		<pubDate>Wed, 08 Jul 2009 15:48:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.64bitjungle.com/?p=282#comment-4565</guid>
		<description>How would you go about doing this recursively to all files/folders under the current directory, i&#039;ve already tried:

grep -lr -e &#039;&#039; *.txt &#124; xargs sed -i &#039;s/plums/apples/g&#039; -R

but no luck.

Any help would be appreciated.</description>
		<content:encoded><![CDATA[<p>How would you go about doing this recursively to all files/folders under the current directory, i&#8217;ve already tried:</p>
<p>grep -lr -e &#8221; *.txt | xargs sed -i &#8216;s/plums/apples/g&#8217; -R</p>
<p>but no luck.</p>
<p>Any help would be appreciated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hodge</title>
		<link>http://www.64bitjungle.com/ubuntu/recursively-search-and-replace-terms-in-multiple-files-with-grep-xargs-and-sed/comment-page-1/#comment-4493</link>
		<dc:creator>Hodge</dc:creator>
		<pubDate>Sun, 05 Jul 2009 16:31:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.64bitjungle.com/?p=282#comment-4493</guid>
		<description>Hi Joe,

You would have to escape the / forward slashes with back slashes \ like so:

&lt;code&gt;grep -lr -e &#039;apples&#039; *.html &#124; xargs sed -i &#039;s/http:\/\/www.example.com\//http:\/\/www.64bitjungle.com\//g&#039;&lt;/code&gt;

Or if you&#039;re just using sed on a single file:

&lt;code&gt;sed -i &#039;s/http:\/\/www.example.com\//http:\/\/www.64bitjungle.com\//g&#039; filename.txt&lt;/code&gt;

Hope that helps</description>
		<content:encoded><![CDATA[<p>Hi Joe,</p>
<p>You would have to escape the / forward slashes with back slashes \ like so:</p>
<p><code>grep -lr -e 'apples' *.html | xargs sed -i 's/http:\/\/www.example.com\//http:\/\/www.64bitjungle.com\//g'</code></p>
<p>Or if you&#8217;re just using sed on a single file:</p>
<p><code>sed -i 's/http:\/\/www.example.com\//http:\/\/www.64bitjungle.com\//g' filename.txt</code></p>
<p>Hope that helps</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: joe</title>
		<link>http://www.64bitjungle.com/ubuntu/recursively-search-and-replace-terms-in-multiple-files-with-grep-xargs-and-sed/comment-page-1/#comment-4491</link>
		<dc:creator>joe</dc:creator>
		<pubDate>Sun, 05 Jul 2009 16:05:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.64bitjungle.com/?p=282#comment-4491</guid>
		<description>how would i go about searching and replacing an url in multiple html files

in your example it says apples/oranges with / being the delimiter but an url has many //&#039;s

how would i go about writing a log of what was edited</description>
		<content:encoded><![CDATA[<p>how would i go about searching and replacing an url in multiple html files</p>
<p>in your example it says apples/oranges with / being the delimiter but an url has many //&#8217;s</p>
<p>how would i go about writing a log of what was edited</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Japan Shah</title>
		<link>http://www.64bitjungle.com/ubuntu/recursively-search-and-replace-terms-in-multiple-files-with-grep-xargs-and-sed/comment-page-1/#comment-2854</link>
		<dc:creator>Japan Shah</dc:creator>
		<pubDate>Wed, 29 Apr 2009 09:07:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.64bitjungle.com/?p=282#comment-2854</guid>
		<description>yes, great 1 more solution is this,
very simple command for unix, linux based operating system.

grep &#039;searchString&#039; DirectoryToSearch --include=*.py -nr</description>
		<content:encoded><![CDATA[<p>yes, great 1 more solution is this,<br />
very simple command for unix, linux based operating system.</p>
<p>grep &#8216;searchString&#8217; DirectoryToSearch &#8211;include=*.py -nr</p>
]]></content:encoded>
	</item>
</channel>
</rss>

