<?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 Joining Lines after  pattern search in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/joining-lines-after-pattern-search/m-p/3368239#M867516</link>
    <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;Is there a way to join several lines every time a pattern is found for e.g&lt;BR /&gt;&lt;BR /&gt;(Disp is a tool to convert binary in a readable format for e.g the output would look like &lt;BR /&gt;&lt;BR /&gt;DSB=fb 00 80 00 01 0a 011616527100 0000 0000 04081c141833 0a 011450225000000000&lt;BR /&gt;+++=   00000010001c0000002d20000101ac024000ad0414001400064a4744484142ce&lt;BR /&gt;+++=   02aa03041023ab08454e5155495234201702e3172d20000000000000009b7500)&lt;BR /&gt;&lt;BR /&gt;Disp Filename | awk '{if($1~/^Chris/){&lt;BR /&gt;hexstr="0123456789abcdef"&lt;BR /&gt;newnum=tolower(substr($8,3,2) substr($8,1,2))&lt;BR /&gt;MONT=tolower(substr($10,3,2))&lt;BR /&gt;....&lt;BR /&gt;....&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;if($1~/^DSB/){&lt;BR /&gt;#--&amp;gt; here I get stuck trying to add "+++=" to every /DSB/ found, because it belongs in the same line. I can use the following statement in a different awk patterns, but certain files contain both Chris and DSB and some only DSB.&lt;BR /&gt;&lt;BR /&gt;awk '/DSB=/{printf "%s%s",sep,$0;sep="\n";next}&lt;BR /&gt;{printf "%s",$0}&lt;BR /&gt;END{print}' | awk '/DSB/{&lt;BR /&gt;&lt;BR /&gt;hexstr="0123456789abcdef"&lt;BR /&gt;newnum=tolower(substr($4,3,2) substr($4,1,2))&lt;BR /&gt;MONT=tolower(substr($10,3,2))&lt;BR /&gt;....&lt;BR /&gt;....&lt;BR /&gt;}&lt;BR /&gt;}'&lt;BR /&gt;&lt;BR /&gt;Many Thanks&lt;BR /&gt;Chris&lt;BR /&gt;</description>
    <pubDate>Mon, 30 Aug 2004 11:26:29 GMT</pubDate>
    <dc:creator>Chris Frangandonis</dc:creator>
    <dc:date>2004-08-30T11:26:29Z</dc:date>
    <item>
      <title>Joining Lines after  pattern search</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/joining-lines-after-pattern-search/m-p/3368239#M867516</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;Is there a way to join several lines every time a pattern is found for e.g&lt;BR /&gt;&lt;BR /&gt;(Disp is a tool to convert binary in a readable format for e.g the output would look like &lt;BR /&gt;&lt;BR /&gt;DSB=fb 00 80 00 01 0a 011616527100 0000 0000 04081c141833 0a 011450225000000000&lt;BR /&gt;+++=   00000010001c0000002d20000101ac024000ad0414001400064a4744484142ce&lt;BR /&gt;+++=   02aa03041023ab08454e5155495234201702e3172d20000000000000009b7500)&lt;BR /&gt;&lt;BR /&gt;Disp Filename | awk '{if($1~/^Chris/){&lt;BR /&gt;hexstr="0123456789abcdef"&lt;BR /&gt;newnum=tolower(substr($8,3,2) substr($8,1,2))&lt;BR /&gt;MONT=tolower(substr($10,3,2))&lt;BR /&gt;....&lt;BR /&gt;....&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;if($1~/^DSB/){&lt;BR /&gt;#--&amp;gt; here I get stuck trying to add "+++=" to every /DSB/ found, because it belongs in the same line. I can use the following statement in a different awk patterns, but certain files contain both Chris and DSB and some only DSB.&lt;BR /&gt;&lt;BR /&gt;awk '/DSB=/{printf "%s%s",sep,$0;sep="\n";next}&lt;BR /&gt;{printf "%s",$0}&lt;BR /&gt;END{print}' | awk '/DSB/{&lt;BR /&gt;&lt;BR /&gt;hexstr="0123456789abcdef"&lt;BR /&gt;newnum=tolower(substr($4,3,2) substr($4,1,2))&lt;BR /&gt;MONT=tolower(substr($10,3,2))&lt;BR /&gt;....&lt;BR /&gt;....&lt;BR /&gt;}&lt;BR /&gt;}'&lt;BR /&gt;&lt;BR /&gt;Many Thanks&lt;BR /&gt;Chris&lt;BR /&gt;</description>
      <pubDate>Mon, 30 Aug 2004 11:26:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/joining-lines-after-pattern-search/m-p/3368239#M867516</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2004-08-30T11:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: Joining Lines after  pattern search</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/joining-lines-after-pattern-search/m-p/3368240#M867517</link>
      <description>Chris -- Could you post a snippet of input and a snippet of output.  I think I can write you up something in awk but I don't understand the before / after look.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 30 Aug 2004 11:44:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/joining-lines-after-pattern-search/m-p/3368240#M867517</guid>
      <dc:creator>Kent Ostby</dc:creator>
      <dc:date>2004-08-30T11:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: Joining Lines after  pattern search</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/joining-lines-after-pattern-search/m-p/3368241#M867518</link>
      <description>How about a small perl one-liner-&lt;BR /&gt; &lt;BR /&gt;Disp Filename | perl -ne 'chomp; print $nl if /^DSB/; print $_; $nl="\n";' -e 'print "\n";'&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Mon, 30 Aug 2004 11:51:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/joining-lines-after-pattern-search/m-p/3368241#M867518</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2004-08-30T11:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: Joining Lines after  pattern search</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/joining-lines-after-pattern-search/m-p/3368242#M867519</link>
      <description>Oops, one change-&lt;BR /&gt; &lt;BR /&gt;Disp Filename | perl -ne 'chomp; print $nl if /^DSB/; print $_; $nl="\n";' -e 'END{print "END\n";}'&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Mon, 30 Aug 2004 11:53:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/joining-lines-after-pattern-search/m-p/3368242#M867519</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2004-08-30T11:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: Joining Lines after  pattern search</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/joining-lines-after-pattern-search/m-p/3368243#M867520</link>
      <description>Hi Kent,&lt;BR /&gt;&lt;BR /&gt;Thanks for the reply.&lt;BR /&gt;&lt;BR /&gt;The before snippet is&lt;BR /&gt;&lt;BR /&gt;1)DSB=fb 00 80 00 01 0a 011616527100 0000 0000 04081c141833 0a 011450225000000000&lt;BR /&gt;&lt;BR /&gt;2)+++=00000010001c0000002d20000101ac024000ad0414001400064a4744484142ce&lt;BR /&gt;3)+++=02aa03041023ab08454e5155495234201702e3172d20000000000000009b7500&lt;BR /&gt;4)DSB=fb 00 80 00 01 0a 039254023500 0000 d801 04081c141834 0a 031462586600000000&lt;BR /&gt;5)+++=0000001000180000001720000102ac026000ad041b001a000644544d484142b9&lt;BR /&gt;6)&lt;BR /&gt;+++=000b&lt;BR /&gt;&lt;BR /&gt;This is were I have a problem in joining these lines. What it should look like before I define (newnum=tolower(substr($4,3,2) substr($4,1,2))&lt;BR /&gt;&lt;BR /&gt;Pionts 1 to 3 is a record for e.g&lt;BR /&gt;DSB=.. .. .. .. .. +++=.. .. .. ... .. .. +++= .... .. .. .. .. .. .. ..&lt;BR /&gt;DSB=.. .. .. .. .. +++=.. .. .. .. +++=.. .. ... is the next record.&lt;BR /&gt;&lt;BR /&gt;Please note that I  first search for /Chris/ and then define etc but when  the next record starts with ^DSB I use the /DSB/ and define ( as shown in my previous post)so that my output could look like plain simple text format for both Chris and DSB for e.g.&lt;BR /&gt;&lt;BR /&gt;And the result whould be&lt;BR /&gt;&lt;BR /&gt;0116165271 2004-08-28 20:24:51         0114502250         0 &lt;BR /&gt;&lt;BR /&gt;Many Thanks&lt;BR /&gt;Chris</description>
      <pubDate>Mon, 30 Aug 2004 12:17:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/joining-lines-after-pattern-search/m-p/3368243#M867520</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2004-08-30T12:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: Joining Lines after  pattern search</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/joining-lines-after-pattern-search/m-p/3368244#M867521</link>
      <description>Chris --&lt;BR /&gt;&lt;BR /&gt;I'm still not sure what you want to do WITH the data, but this script will combine the lines for you and then you can put your magic in the two spots where I have "Do Stuff" listed.&lt;BR /&gt;&lt;BR /&gt;BEGIN {started=0;}&lt;BR /&gt;/^DBS/ {if (started &amp;gt; 0 )&lt;BR /&gt;          {Do stuff };&lt;BR /&gt;        started=1; keptline=$0;&lt;BR /&gt;        next;}&lt;BR /&gt;{keptline=keptline $0;}&lt;BR /&gt;END {Do stuff}&lt;BR /&gt;</description>
      <pubDate>Mon, 30 Aug 2004 12:26:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/joining-lines-after-pattern-search/m-p/3368244#M867521</guid>
      <dc:creator>Kent Ostby</dc:creator>
      <dc:date>2004-08-30T12:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: Joining Lines after  pattern search</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/joining-lines-after-pattern-search/m-p/3368245#M867522</link>
      <description>Hi Kent,&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Part of my Script looks like this&lt;BR /&gt;&lt;BR /&gt; $RAW $2 |awk '{&lt;BR /&gt;                                                       if($1~/Chris/){&lt;BR /&gt;                                                       for (e=1;e&lt;NF&gt;&lt;/NF&gt;                                                       LA=$(e+4)&lt;BR /&gt;                                                       {if ($(e+4)==00){&lt;BR /&gt;                                                       Anum="NULL"&lt;BR /&gt;                                                       }else{&lt;BR /&gt;                                                       A_num=$(e+5)&lt;BR /&gt;                                                       }}}&lt;BR /&gt;                                                       if($e~/P=65/){&lt;BR /&gt;                                                       BNUM=$(e+2)&lt;BR /&gt;                                                       LN=$(e+1)&lt;BR /&gt;                                                       }&lt;BR /&gt;                                                       if($e~/P=64/){&lt;BR /&gt;                                                       DATE=$(e+1)&lt;BR /&gt;                                                       DUR=$(e+3)&lt;BR /&gt;                                                       }&lt;BR /&gt;                                                       if($e~/P=67/){&lt;BR /&gt;                                                       UN=$(e+1)&lt;BR /&gt;                                                       }}&lt;BR /&gt;                                                      hexstr="0123456789abcdef"&lt;BR /&gt;                                                       newnum=tolower(substr(DUR,5,2) substr(DUR,3,2) substr(DUR,1,2))&lt;BR /&gt;                                                       YEAR=tolower(substr(DATE,1,2))&lt;BR /&gt;                                                       MONT=tolower(substr(DATE,3,2))&lt;BR /&gt;                                                       DAY=tolower(substr(DATE,5,2))&lt;BR /&gt;                                                       HOUR=tolower(substr(DATE,7,2))&lt;BR /&gt;           ................&lt;BR /&gt;printf ("%15s  %.2d-%.2d-%.2d %.2d:%......&lt;BR /&gt;           } &lt;BR /&gt;          }&lt;BR /&gt;                                                                if($1~/DSB=/){&lt;BR /&gt;                                                hexstr="0123456789abcdef"&lt;BR /&gt;                                                 newnum=tolower(substr($9,3,2) substr($9,1,2))&lt;BR /&gt;                                                 YEAR=tolower(substr($10,1,2))&lt;BR /&gt;                                                 MONT=tolower(substr($10,3,2))&lt;BR /&gt;                                                 DAY=tolower(substr($10,5,2))&lt;BR /&gt;                                                 HOUR=tolower(substr($10,7,2))&lt;BR /&gt;                                                 MIN=tolower(substr($10,9,2))&lt;BR /&gt;     ...........................&lt;BR /&gt;     printf ("%11s %.2d-%.2d-%.2d %.2d:%.2d:%.2&lt;BR /&gt; } &lt;BR /&gt;}'&lt;BR /&gt;&lt;BR /&gt;Please note that Chris format differs to the DSB one and yes to your answer, after the +++= there is additional info that I require.&lt;BR /&gt;&lt;BR /&gt;How could I use your script in this case????&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks Once Agaqin&lt;BR /&gt;Chris</description>
      <pubDate>Mon, 30 Aug 2004 12:40:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/joining-lines-after-pattern-search/m-p/3368245#M867522</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2004-08-30T12:40:03Z</dc:date>
    </item>
  </channel>
</rss>

