<?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 How to find and replace multiple lines. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-find-and-replace-multiple-lines/m-p/4684408#M658762</link>
    <description>Hello.&lt;BR /&gt;I have a input file containing multiple sets of following text:&lt;BR /&gt;----------------&lt;BR /&gt;:59:/1234567890&lt;BR /&gt;LINE1&lt;BR /&gt;LINE2&lt;BR /&gt;LINE3&lt;BR /&gt;:50:/9856958654&lt;BR /&gt;LINE1&lt;BR /&gt;LINE2&lt;BR /&gt;----------------&lt;BR /&gt;&lt;BR /&gt;Basically, Tag 59 and Tag50 can have any number of lines in the input and any number against it. I want to write a script so that tag50 and tag59 could be found and the strings could be replaced as below:&lt;BR /&gt;&lt;BR /&gt;----------------&lt;BR /&gt;:59:/XXXXXXXXXX&lt;BR /&gt;ZZZZZZZZ&lt;BR /&gt;ZZZZZZZZ&lt;BR /&gt;ZZZZZZZZ&lt;BR /&gt;:50:/XXXXXXXXXX&lt;BR /&gt;ZZZZZZZZ&lt;BR /&gt;ZZZZZZZZ&lt;BR /&gt;----------------&lt;BR /&gt;&lt;BR /&gt;Your help will be highly appreciated. Thank you.</description>
    <pubDate>Wed, 08 Sep 2010 06:05:19 GMT</pubDate>
    <dc:creator>panchpan</dc:creator>
    <dc:date>2010-09-08T06:05:19Z</dc:date>
    <item>
      <title>How to find and replace multiple lines.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-find-and-replace-multiple-lines/m-p/4684408#M658762</link>
      <description>Hello.&lt;BR /&gt;I have a input file containing multiple sets of following text:&lt;BR /&gt;----------------&lt;BR /&gt;:59:/1234567890&lt;BR /&gt;LINE1&lt;BR /&gt;LINE2&lt;BR /&gt;LINE3&lt;BR /&gt;:50:/9856958654&lt;BR /&gt;LINE1&lt;BR /&gt;LINE2&lt;BR /&gt;----------------&lt;BR /&gt;&lt;BR /&gt;Basically, Tag 59 and Tag50 can have any number of lines in the input and any number against it. I want to write a script so that tag50 and tag59 could be found and the strings could be replaced as below:&lt;BR /&gt;&lt;BR /&gt;----------------&lt;BR /&gt;:59:/XXXXXXXXXX&lt;BR /&gt;ZZZZZZZZ&lt;BR /&gt;ZZZZZZZZ&lt;BR /&gt;ZZZZZZZZ&lt;BR /&gt;:50:/XXXXXXXXXX&lt;BR /&gt;ZZZZZZZZ&lt;BR /&gt;ZZZZZZZZ&lt;BR /&gt;----------------&lt;BR /&gt;&lt;BR /&gt;Your help will be highly appreciated. Thank you.</description>
      <pubDate>Wed, 08 Sep 2010 06:05:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-find-and-replace-multiple-lines/m-p/4684408#M658762</guid>
      <dc:creator>panchpan</dc:creator>
      <dc:date>2010-09-08T06:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to find and replace multiple lines.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-find-and-replace-multiple-lines/m-p/4684409#M658763</link>
      <description>&lt;!--!*#--&gt;&amp;gt;Tag 59 and Tag50 can have any number of lines in the input and any number against it.&lt;BR /&gt;&lt;BR /&gt;So if you see :50: or :59: you want to replace the string on that line and up to a line with :XX: with "X" then "Z"?&lt;BR /&gt;&lt;BR /&gt;Perhaps something like this:&lt;BR /&gt;awk '&lt;BR /&gt;BEGIN {&lt;BR /&gt;  str1 = "/XXXXXXXXXX"&lt;BR /&gt;  str2 = "ZZZZZZZZ"&lt;BR /&gt;  replace = 0&lt;BR /&gt;}&lt;BR /&gt;substr($0, 1, 4) == ":50:" ||&lt;BR /&gt;substr($0, 1, 4) == ":59:" {&lt;BR /&gt;   replace = 1&lt;BR /&gt;   print substr($0, 1, 4) str1&lt;BR /&gt;   next&lt;BR /&gt;}&lt;BR /&gt;substr($0, 1, 1) == ":" { # new tag?&lt;BR /&gt;   replace = 0&lt;BR /&gt;}&lt;BR /&gt;replace {&lt;BR /&gt;   print str2&lt;BR /&gt;   next&lt;BR /&gt;}&lt;BR /&gt;{&lt;BR /&gt;   print $0  # copy line&lt;BR /&gt;}' file</description>
      <pubDate>Wed, 08 Sep 2010 07:37:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-find-and-replace-multiple-lines/m-p/4684409#M658763</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2010-09-08T07:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to find and replace multiple lines.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-find-and-replace-multiple-lines/m-p/4684410#M658764</link>
      <description>&lt;!--!*#--&gt;Hi:&lt;BR /&gt;&lt;BR /&gt;Here's a solution based on your requirements' definition:&lt;BR /&gt;&lt;BR /&gt;# cat ./filter&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;local $/ = undef;&lt;BR /&gt;my @pieces = split( /(?=:\d+:\/.+)/, &amp;lt;&amp;gt; );&lt;BR /&gt;for (@pieces) {&lt;BR /&gt;    my @subpieces = split( /$/m, $_ );&lt;BR /&gt;    if (/^(:(50|59):\/)/) {&lt;BR /&gt;        print $1, "XXXXXXXXXX\n";&lt;BR /&gt;        shift @subpieces;&lt;BR /&gt;        print "ZZZZZZZZZ\n" for ( 1 .. @subpieces - 1 );&lt;BR /&gt;    }&lt;BR /&gt;    else {&lt;BR /&gt;        print $_;&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;...run as:&lt;BR /&gt;&lt;BR /&gt;# ./filter file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 08 Sep 2010 12:59:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-find-and-replace-multiple-lines/m-p/4684410#M658764</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-09-08T12:59:10Z</dc:date>
    </item>
  </channel>
</rss>

