<?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: Strings replacement help needed in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/strings-replacement-help-needed/m-p/4407445#M352571</link>
    <description>I would use VI and search/replace with a regexp.&lt;BR /&gt;&lt;BR /&gt;open the file and write:&lt;BR /&gt;:%s/search_pattern/replace_pattern/gc&lt;BR /&gt;&lt;BR /&gt;the gc option at the end means "do this globally and confirm" then just press y or n to answer yes or no.&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;Fredrik Eriksson</description>
    <pubDate>Mon, 27 Apr 2009 09:36:50 GMT</pubDate>
    <dc:creator>Fredrik.eriksson</dc:creator>
    <dc:date>2009-04-27T09:36:50Z</dc:date>
    <item>
      <title>Strings replacement help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/strings-replacement-help-needed/m-p/4407435#M352561</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;   I have to replace a string in a file of 1000 lines. That string is distributed and i want to replace only 200 lines out of 1000 lines of that particular strings.&lt;BR /&gt;&lt;BR /&gt;It should be in interactive mode where i can get the information before replacing that string.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.&lt;BR /&gt;Waiting for the earliset response.</description>
      <pubDate>Fri, 24 Apr 2009 10:53:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/strings-replacement-help-needed/m-p/4407435#M352561</guid>
      <dc:creator>Md.Shahabuddin</dc:creator>
      <dc:date>2009-04-24T10:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: Strings replacement help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/strings-replacement-help-needed/m-p/4407436#M352562</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Try this:&lt;BR /&gt;&lt;BR /&gt;# perl -pe 'if ($n&amp;lt;200) {$n++ if s/XX/YY/g}' file&lt;BR /&gt;&lt;BR /&gt;Change "XX" and "YY" to the patterns you need.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 24 Apr 2009 11:32:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/strings-replacement-help-needed/m-p/4407436#M352562</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-04-24T11:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: Strings replacement help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/strings-replacement-help-needed/m-p/4407437#M352563</link>
      <description>I believe the perl above is going to change the first 200 occurrances, while the request seems to be for 200 out of 1000, and he need to inspect it before commiting the change.&lt;BR /&gt;&lt;BR /&gt;in this case I'd use vi.&lt;BR /&gt;&lt;BR /&gt;to search:&lt;BR /&gt;/&lt;OSTRING&gt;   where &lt;OSTRING&gt; is the old text&lt;BR /&gt;then "n" to locate the next occurance&lt;BR /&gt;&lt;BR /&gt;method of replacement is going to vary depending on if its a 'word', or exactly the same length or buried in some longer string...&lt;BR /&gt;&lt;BR /&gt;insuffficient information for a complete answer.&lt;/OSTRING&gt;&lt;/OSTRING&gt;</description>
      <pubDate>Fri, 24 Apr 2009 12:04:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/strings-replacement-help-needed/m-p/4407437#M352563</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2009-04-24T12:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: Strings replacement help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/strings-replacement-help-needed/m-p/4407438#M352564</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;The Perl script I suggested replaces up to 200-lines regardless of how many matches occur per line.&lt;BR /&gt;&lt;BR /&gt;It is trivial to modify the substitution to "words" or simply any string sequence as I used.&lt;BR /&gt;&lt;BR /&gt;I agree that more information would lead to a more complete answer.&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 24 Apr 2009 12:49:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/strings-replacement-help-needed/m-p/4407438#M352564</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-04-24T12:49:25Z</dc:date>
    </item>
    <item>
      <title>Re: Strings replacement help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/strings-replacement-help-needed/m-p/4407439#M352565</link>
      <description>&lt;BR /&gt;James.....&lt;BR /&gt;&lt;BR /&gt;Thank you so much. Its working.</description>
      <pubDate>Fri, 24 Apr 2009 13:04:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/strings-replacement-help-needed/m-p/4407439#M352565</guid>
      <dc:creator>Md.Shahabuddin</dc:creator>
      <dc:date>2009-04-24T13:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: Strings replacement help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/strings-replacement-help-needed/m-p/4407440#M352566</link>
      <description>JRF: I read this "It should be in interactive mode where i can get the information before replacing that string."&lt;BR /&gt;&lt;BR /&gt;as "I need to see it in context before confirming change"...which apparently isn't the case&lt;BR /&gt;</description>
      <pubDate>Fri, 24 Apr 2009 13:32:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/strings-replacement-help-needed/m-p/4407440#M352566</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2009-04-24T13:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: Strings replacement help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/strings-replacement-help-needed/m-p/4407441#M352567</link>
      <description>U are right James.&lt;BR /&gt;&lt;BR /&gt;can it be done in interactive mode?&lt;BR /&gt;Do u have any alternatives?&lt;BR /&gt;</description>
      <pubDate>Fri, 24 Apr 2009 13:37:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/strings-replacement-help-needed/m-p/4407441#M352567</guid>
      <dc:creator>Md.Shahabuddin</dc:creator>
      <dc:date>2009-04-24T13:37:19Z</dc:date>
    </item>
    <item>
      <title>Re: Strings replacement help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/strings-replacement-help-needed/m-p/4407442#M352568</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;No, I made no provisions for doing this "interactively".  I find it hard to imagine why you want to replace 200 of 1000 lines "interactively", which to me suggests confimation as you proceed.  If this is true, do you count a line toward the "200" if you reject its change or only if you accept it?&lt;BR /&gt;&lt;BR /&gt;Since I left the input file un-modified, I felt that this was an adequate "interactive" preview step in and of itself.  Re-running the script after inspecting the results would then only require a simple redirection to a new output file or the change of the Perl swithes from '-pe' to '-pi -e' to affect an in-place update.&lt;BR /&gt;&lt;BR /&gt;I interpreted your original question to mean _lines_ on which substitutions occur regardless of how many _times_ per line a substitution was made.  How would that factor into your count toward "200" if you were to ask for confirmation at each step?&lt;BR /&gt;&lt;BR /&gt;What is the problem you really want to solve?  If it isn't an on-going one, using 'vi' as Oldschool suggested might be the fastest solution.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 24 Apr 2009 13:56:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/strings-replacement-help-needed/m-p/4407442#M352568</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-04-24T13:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: Strings replacement help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/strings-replacement-help-needed/m-p/4407443#M352569</link>
      <description>Hi,&lt;BR /&gt;I have to use VI and a lot of patience.&lt;BR /&gt;Find the string (/) and replace it (r), find next occurrence (n) and replace it (.) and so on.&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Art</description>
      <pubDate>Mon, 27 Apr 2009 06:07:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/strings-replacement-help-needed/m-p/4407443#M352569</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2009-04-27T06:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: Strings replacement help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/strings-replacement-help-needed/m-p/4407444#M352570</link>
      <description>&amp;gt;Art: Find the string (/) and replace it (r), find next occurrence (n) and replace it (.)&lt;BR /&gt;&lt;BR /&gt;You can also use:&lt;BR /&gt;:first,last s/string1/string2/gc&lt;BR /&gt;&lt;BR /&gt;The "c" asks you to confirm for each line.</description>
      <pubDate>Mon, 27 Apr 2009 06:16:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/strings-replacement-help-needed/m-p/4407444#M352570</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-04-27T06:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: Strings replacement help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/strings-replacement-help-needed/m-p/4407445#M352571</link>
      <description>I would use VI and search/replace with a regexp.&lt;BR /&gt;&lt;BR /&gt;open the file and write:&lt;BR /&gt;:%s/search_pattern/replace_pattern/gc&lt;BR /&gt;&lt;BR /&gt;the gc option at the end means "do this globally and confirm" then just press y or n to answer yes or no.&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;Fredrik Eriksson</description>
      <pubDate>Mon, 27 Apr 2009 09:36:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/strings-replacement-help-needed/m-p/4407445#M352571</guid>
      <dc:creator>Fredrik.eriksson</dc:creator>
      <dc:date>2009-04-27T09:36:50Z</dc:date>
    </item>
  </channel>
</rss>

