<?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: How Do I Replace A Text String In Many Files At Once?</title> <atom:link href="http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html/feed" rel="self" type="application/rss+xml" /><link>http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html</link> <description>This is a Linux sys admin journal by Vivek about sys admin work, Linux tips &#38; tricks, hacks, news and more.</description> <lastBuildDate>Fri, 10 Feb 2012 20:37:43 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: saravanan</title><link>http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-177976</link> <dc:creator>saravanan</dc:creator> <pubDate>Wed, 04 Jan 2012 14:35:36 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-177976</guid> <description>I want to replace a string in sub directories also(in Linux), is there any specific command for that?</description> <content:encoded><![CDATA[<p>I want to replace a string in sub directories also(in Linux), is there any specific command for that?</p> ]]></content:encoded> </item> <item><title>By: Ben</title><link>http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-169598</link> <dc:creator>Ben</dc:creator> <pubDate>Mon, 07 Mar 2011 04:23:20 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-169598</guid> <description>&#039;Replace&#039; is found in mySQL.  If you don&#039;t have mySQL, you don&#039;t have `replace`</description> <content:encoded><![CDATA[<p>&#8216;Replace&#8217; is found in mySQL.  If you don&#8217;t have mySQL, you don&#8217;t have `replace`</p> ]]></content:encoded> </item> <item><title>By: DougTheBug</title><link>http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-158983</link> <dc:creator>DougTheBug</dc:creator> <pubDate>Tue, 17 Aug 2010 22:07:26 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-158983</guid> <description>I couldn&#039;t even find this command in Ubunto 10.04 (or in repositories). I ended up using rpl instead. Is really fun for databending images.</description> <content:encoded><![CDATA[<p>I couldn&#8217;t even find this command in Ubunto 10.04 (or in repositories). I ended up using rpl instead. Is really fun for databending images.</p> ]]></content:encoded> </item> <item><title>By: Matthew Scott</title><link>http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-158186</link> <dc:creator>Matthew Scott</dc:creator> <pubDate>Sun, 18 Jul 2010 03:46:13 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-158186</guid> <description>`replace` can work with files, which may be simpler than writing a shell script as mentioned above.  It will even convert files in place.  Say you want to change an instance of &#039;foo&#039; to &#039;bar&#039; in all files in a certain directory, recursively.  In bash,
for i in `grep -lR foo dir/to/files`; do replace foo bar -- $i; done
Simply put, use two dashes to separate filenames from the from/to strings, and it&#039;ll convert the files.</description> <content:encoded><![CDATA[<p>`replace` can work with files, which may be simpler than writing a shell script as mentioned above.  It will even convert files in place.  Say you want to change an instance of &#8216;foo&#8217; to &#8216;bar&#8217; in all files in a certain directory, recursively.  In bash,</p><p>for i in `grep -lR foo dir/to/files`; do replace foo bar &#8212; $i; done</p><p>Simply put, use two dashes to separate filenames from the from/to strings, and it&#8217;ll convert the files.</p> ]]></content:encoded> </item> <item><title>By: Matthew Scott</title><link>http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-158185</link> <dc:creator>Matthew Scott</dc:creator> <pubDate>Sun, 18 Jul 2010 03:43:12 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-158185</guid> <description>`replace`</description> <content:encoded><![CDATA[<p>`replace`</p> ]]></content:encoded> </item> <item><title>By: 2046</title><link>http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-147923</link> <dc:creator>2046</dc:creator> <pubDate>Tue, 31 Mar 2009 18:09:51 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-147923</guid> <description>&lt;code&gt;find ./* -type f -exec sed -i &#039;s///g&#039; {} \;&lt;/code&gt;</description> <content:encoded><![CDATA[<p><code>find ./* -type f -exec sed -i 's///g' {} \;</code></p> ]]></content:encoded> </item> <item><title>By: Eden</title><link>http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-147135</link> <dc:creator>Eden</dc:creator> <pubDate>Wed, 11 Feb 2009 00:21:08 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-147135</guid> <description>Cant see the diference... :(</description> <content:encoded><![CDATA[<p>Cant see the diference&#8230; :(</p> ]]></content:encoded> </item> <item><title>By: lefty.crupps</title><link>http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-144076</link> <dc:creator>lefty.crupps</dc:creator> <pubDate>Mon, 16 Jun 2008 16:28:56 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-144076</guid> <description>Am I the only one who sees no difference in these?
&gt;&gt; perl -p -i -e ’s/&#124;00000000.00&#124;/&#124;&#124;/g’ myfile.txt
&gt;&gt; I want to replace &#124;00000000.00&#124; with &#124;&#124;
&gt;&gt; I get a compilation error.
--- ---
&gt;&gt; You need to write it as follows:
&gt;&gt; perl -p -i -e ’s/&#124;00000000.00&#124;/&#124;&#124;/g’ myfile.txt</description> <content:encoded><![CDATA[<p>Am I the only one who sees no difference in these?</p><p>&gt;&gt; perl -p -i -e ’s/|00000000.00|/||/g’ myfile.txt<br
/> &gt;&gt; I want to replace |00000000.00| with ||<br
/> &gt;&gt; I get a compilation error.</p><p>&#8212; &#8212;<br
/> &gt;&gt; You need to write it as follows:<br
/> &gt;&gt; perl -p -i -e ’s/|00000000.00|/||/g’ myfile.txt</p> ]]></content:encoded> </item> <item><title>By: Raj</title><link>http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-143420</link> <dc:creator>Raj</dc:creator> <pubDate>Thu, 10 Apr 2008 13:25:32 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-143420</guid> <description>thanks for sharing this info</description> <content:encoded><![CDATA[<p>thanks for sharing this info</p> ]]></content:encoded> </item> <item><title>By: walter</title><link>http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-140733</link> <dc:creator>walter</dc:creator> <pubDate>Thu, 09 Aug 2007 06:59:39 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-140733</guid> <description>or try this...
first make a bash script, &#039;fixer.sh&#039;
&lt;code&gt;
#!/bin/bash
replace CHANGEFROM CHANGETO  $1.tmp
rm $1
mv $1.tmp $1
&lt;/code&gt;
now run this command line...
&lt;code&gt;
$ grep CHANGEFROM &#124;cut -d&#039;:&#039; -f1 &#124;xargs -n 1 fixer.sh
&lt;/code&gt;
the results is that all files in the directory (or whatever you grep for) will be changed automagically.
just make sure the grep doesn&#039;t include the fixer script itself, or it will die half-way through changing when execute permissions are reset!
;)</description> <content:encoded><![CDATA[<p>or try this&#8230;<br
/> first make a bash script, &#8216;fixer.sh&#8217;</p><p><code><br
/> #!/bin/bash<br
/> replace CHANGEFROM CHANGETO  $1.tmp<br
/> rm $1<br
/> mv $1.tmp $1<br
/> </code></p><p>now run this command line&#8230;<br
/> <code><br
/> $ grep CHANGEFROM |cut -d':' -f1 |xargs -n 1 fixer.sh<br
/> </code></p><p>the results is that all files in the directory (or whatever you grep for) will be changed automagically.</p><p>just make sure the grep doesn&#8217;t include the fixer script itself, or it will die half-way through changing when execute permissions are reset!</p><p>;)</p> ]]></content:encoded> </item> <item><title>By: Anonymous</title><link>http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-19299</link> <dc:creator>Anonymous</dc:creator> <pubDate>Mon, 12 Dec 2005 21:02:00 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-19299</guid> <description>This does the trick perfectly! Thanks for sharing this special character technique nixcraft!</description> <content:encoded><![CDATA[<p>This does the trick perfectly! Thanks for sharing this special character technique nixcraft!</p> ]]></content:encoded> </item> <item><title>By: nixcraft</title><link>http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-19298</link> <dc:creator>nixcraft</dc:creator> <pubDate>Mon, 12 Dec 2005 01:41:00 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-19298</guid> <description>You need to write it as follows:
perl -p -i -e &#039;s/&#124;00000000.00&#124;/&#124;&#124;/g&#039; myfile.txt
&#124;&#124; got some special meaning (regex) &#124; will disable it</description> <content:encoded><![CDATA[<p>You need to write it as follows:</p><p>perl -p -i -e &#8216;s/|00000000.00|/||/g&#8217; myfile.txt</p><p>|| got some special meaning (regex) | will disable it</p> ]]></content:encoded> </item> <item><title>By: Anonymous</title><link>http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-19297</link> <dc:creator>Anonymous</dc:creator> <pubDate>Mon, 12 Dec 2005 00:13:00 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-19297</guid> <description>what about this line:
perl -p -i -e &#039;s/&#124;00000000.00&#124;/&#124;&#124;/g&#039; myfile.txt
I want to replace &#124;00000000.00&#124; with &#124;&#124;
I get a compilation error.</description> <content:encoded><![CDATA[<p>what about this line:</p><p>perl -p -i -e &#8216;s/|00000000.00|/||/g&#8217; myfile.txt</p><p>I want to replace |00000000.00| with ||</p><p>I get a compilation error.</p> ]]></content:encoded> </item> <item><title>By: Anonymous</title><link>http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-19296</link> <dc:creator>Anonymous</dc:creator> <pubDate>Wed, 30 Nov 2005 09:34:00 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-19296</guid> <description>http://www.debian-administration.org/articles/298 has a fine article and discussion on Perl Pie.</description> <content:encoded><![CDATA[<p><a
href="http://www.debian-administration.org/articles/298" rel="nofollow">http://www.debian-administration.org/articles/298</a> has a fine article and discussion on Perl Pie.</p> ]]></content:encoded> </item> <item><title>By: LinuxTitli</title><link>http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-19295</link> <dc:creator>LinuxTitli</dc:creator> <pubDate>Sat, 12 Nov 2005 23:47:00 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-19295</guid> <description>Joe, very nice. Your tip sound yummy :) thanks for sharing with us</description> <content:encoded><![CDATA[<p>Joe, very nice. Your tip sound yummy :) thanks for sharing with us</p> ]]></content:encoded> </item> <item><title>By: Joe</title><link>http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-19294</link> <dc:creator>Joe</dc:creator> <pubDate>Sat, 12 Nov 2005 23:30:00 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/how-do-i-replace-text-string-in-many-files-at-once.html#comment-19294</guid> <description>To use perl, just remember Perl Pie!
perl -p -i -e &#039;s/hello/goodbye/g&#039; textfile.txt</description> <content:encoded><![CDATA[<p>To use perl, just remember Perl Pie!</p><p>perl -p -i -e &#8216;s/hello/goodbye/g&#8217; textfile.txt</p> ]]></content:encoded> </item> </channel> </rss>
