<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: search &amp;amp; replace in all files in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/search-n-r-eplace-in-all-files/m-p/4836835#M641685</link>
    <description>&lt;P&gt;hi Guys ,&lt;/P&gt;&lt;P&gt;I went&amp;nbsp; ahead with the perl option given by James.&lt;/P&gt;&lt;P&gt;It worked like a charm....for me modification time was not imp..just the replacement was.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks .&lt;/P&gt;</description>
    <pubDate>Fri, 22 Jul 2011 12:27:42 GMT</pubDate>
    <dc:creator>zxcv</dc:creator>
    <dc:date>2011-07-22T12:27:42Z</dc:date>
    <item>
      <title>search n r eplace in all files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-n-r-eplace-in-all-files/m-p/4836375#M641681</link>
      <description>&lt;P&gt;Hi guys ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i would like to search for a patern in all subdirectories and then replace the same with another name..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;say grep "hello" in /home/test&amp;nbsp; to be replaced with "world" in all the files under /home/test &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2011 05:21:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-n-r-eplace-in-all-files/m-p/4836375#M641681</guid>
      <dc:creator>zxcv</dc:creator>
      <dc:date>2011-07-22T05:21:34Z</dc:date>
    </item>
    <item>
      <title>Re: search n r eplace in all files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-n-r-eplace-in-all-files/m-p/4836543#M641682</link>
      <description>Hi guys got it thnxx&lt;BR /&gt;&lt;BR /&gt;find ./ -type f -exec sed -i ‘s/string1/string2/’ {} \;</description>
      <pubDate>Fri, 22 Jul 2011 07:59:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-n-r-eplace-in-all-files/m-p/4836543#M641682</guid>
      <dc:creator>zxcv</dc:creator>
      <dc:date>2011-07-22T07:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: search &amp; replace in all files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-n-r-eplace-in-all-files/m-p/4836691#M641683</link>
      <description>&lt;P&gt;&amp;gt;find ./ -type f -exec sed -i ‘s/string1/string2/’ {} \; ﻿&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HP-UX's sed doesn't have -i.&lt;/P&gt;&lt;P&gt;Also your sed replacement will do substrings.&lt;/P&gt;&lt;P&gt;And if the file doesn't have string1, do you really want to change the modification time?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2011 11:02:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-n-r-eplace-in-all-files/m-p/4836691#M641683</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-07-22T11:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: search &amp; replace in all files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-n-r-eplace-in-all-files/m-p/4836799#M641684</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.hpe.com/t5/user/viewprofilepage/user-id/22676"&gt;@Dennis Handly&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;&amp;gt;find ./ -type f -exec sed -i ‘s/string1/string2/’ {} \; ﻿&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HP-UX's sed doesn't have -i.&lt;/P&gt;&lt;P&gt;Also your sed replacement will do substrings.&lt;/P&gt;&lt;P&gt;And if the file doesn't have string1, do you really want to change the modification time?&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As noted, HP-UX 'sed' lacks the GNU extension for in-place editing.&amp;nbsp; Perl doesn't and it's available on virtually every HP-UX platform.&amp;nbsp; Perl's regular expressions can easily address matching substrings or not, too﻿.&amp;nbsp; As for not updating files without matches, this one-liner would need to be enhanced slightly.&amp;nbsp; All said:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# find . -type f -exec perl -pi.old -e&amp;nbsp; ‘s/\bstring1\b/string2/’ {} +&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will process multiple files for every Perl process forked.&amp;nbsp; Files will be updated in-place with a backup before modification as "*.old".&amp;nbsp; The addition of the '\b' (boundry) surrounding the string to be matched tightens the criteria for replacement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...JRF...&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2011 12:08:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-n-r-eplace-in-all-files/m-p/4836799#M641684</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-07-22T12:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: search &amp; replace in all files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-n-r-eplace-in-all-files/m-p/4836835#M641685</link>
      <description>&lt;P&gt;hi Guys ,&lt;/P&gt;&lt;P&gt;I went&amp;nbsp; ahead with the perl option given by James.&lt;/P&gt;&lt;P&gt;It worked like a charm....for me modification time was not imp..just the replacement was.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks .&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2011 12:27:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-n-r-eplace-in-all-files/m-p/4836835#M641685</guid>
      <dc:creator>zxcv</dc:creator>
      <dc:date>2011-07-22T12:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: search &amp; replace in all files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-n-r-eplace-in-all-files/m-p/4836839#M641686</link>
      <description>Thanks dennis for the -i option...info</description>
      <pubDate>Fri, 22 Jul 2011 12:28:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-n-r-eplace-in-all-files/m-p/4836839#M641686</guid>
      <dc:creator>zxcv</dc:creator>
      <dc:date>2011-07-22T12:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: search &amp; replace in all files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-n-r-eplace-in-all-files/m-p/4836851#M641687</link>
      <description>&lt;P&gt;&amp;gt;Thanks Dennis for the -i option info&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: GNU sed has that -i.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2011 12:37:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-n-r-eplace-in-all-files/m-p/4836851#M641687</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-07-22T12:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: search &amp; replace in all files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-n-r-eplace-in-all-files/m-p/4836901#M641688</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.hpe.com/t5/user/viewprofilepage/user-id/22676"&gt;@Dennis Handly&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;&amp;gt;Thanks Dennis for the -i option info&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: GNU sed has that -i.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Dennis, that's what I noted in my original response :-) You usually read better ;-)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...JRF...&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2011 13:04:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-n-r-eplace-in-all-files/m-p/4836901#M641688</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-07-22T13:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: search &amp; replace in all files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-n-r-eplace-in-all-files/m-p/4836967#M641689</link>
      <description>&lt;P&gt;&amp;gt;that's what I noted in my original response﻿&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess I read that as Linux, rather than gnu that you could install on your HP-UX system.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2011 13:51:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-n-r-eplace-in-all-files/m-p/4836967#M641689</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-07-22T13:51:36Z</dc:date>
    </item>
  </channel>
</rss>

