<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Replace on Amit Agarwal Linux Blog</title>
    <link>/tags/replace/</link>
    <description>Recent content in Replace on Amit Agarwal Linux Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Fri, 25 Jun 2010 11:46:55 +0000</lastBuildDate>
    
	<atom:link href="/tags/replace/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>remove/replace text/path in config file.</title>
      <link>/2010/06/25/removereplace-textpath-in-config-file/</link>
      <pubDate>Fri, 25 Jun 2010 11:46:55 +0000</pubDate>
      
      <guid>/2010/06/25/removereplace-textpath-in-config-file/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;Lot of times I end up changing a particular text in config file to some other text. And when I have to do it for multiple files, all files having the text in multiple places, I end up opening the files in vim and then doing a globlal replace. But this is not efficient so I cam up with some one liners to do this for me. For removing any occurance of text in all files in the directory :&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Quickly search and replace string with Regular expression in multiple files using perl</title>
      <link>/2010/01/27/quickly-search-and-replace-string-with-regular-expression-in-multiple-files-using-perl/</link>
      <pubDate>Wed, 27 Jan 2010 07:45:45 +0000</pubDate>
      
      <guid>/2010/01/27/quickly-search-and-replace-string-with-regular-expression-in-multiple-files-using-perl/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;
&lt;blockquote&gt;
&lt;p&gt;for i in *; do perl -p -w -e &amp;amp;#8217;s/a(.*)b.*/d$1e/g&amp;amp;#8217;  $i &amp;gt; temp/$i; done&lt;/p&gt;
&lt;p&gt;for i in *; do perl -pi -w -e &amp;amp;#8217;s/a(.*)b.*/d$1e/g&amp;amp;#8217;  $i ; done&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The first one can be used when you want to preserve the original file. The redirection will cause the file with replaced string to be written to the new location in the temp directory. Modify the same according to your needs.&lt;/p&gt;
&lt;p&gt;The second can be used to modify the files in-line. Causing overwriting the original file.&lt;/p&gt;</description>
    </item>
    
  </channel>
</rss>
