<?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: parsing problem..shell script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-problem-shell-script/m-p/4130165#M727675</link>
    <description>also...:(&lt;BR /&gt;can U help me with code explanation..I do not know purpose of this x variable..:(</description>
    <pubDate>Wed, 16 Jan 2008 13:06:40 GMT</pubDate>
    <dc:creator>amonamon</dc:creator>
    <dc:date>2008-01-16T13:06:40Z</dc:date>
    <item>
      <title>parsing problem..shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-problem-shell-script/m-p/4130160#M727670</link>
      <description>Hello I am using ksh, and would appreciate if someone could help me started with this phase:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;My file has amoung all..those pattern lines(they change..):&lt;BR /&gt;Does not have to have 22 lines...sometimes 10 sometimes 30 or more&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;...&lt;BR /&gt;...&lt;BR /&gt;..&lt;BR /&gt;2008-01-16 09:10:39,103  INFO [http-8080-Processor11235]  (PaymentRequestFactory.java:640) -payment.processing.Request(&lt;BR /&gt;accessID         = "Internet"&lt;BR /&gt;accountType      = payment.processing.AccountType(&lt;BR /&gt;        value    = 1&lt;BR /&gt;        )&lt;BR /&gt;sum   = 1&lt;BR /&gt;AccountID        = 0&lt;BR /&gt;consumerID       = "33333333333"&lt;BR /&gt;consumerPIN      = ""&lt;BR /&gt;currency         = "RAT"&lt;BR /&gt;merchantID       = "C"&lt;BR /&gt;name     = "Request"&lt;BR /&gt;pin      = ""&lt;BR /&gt;productID        = "Roam"&lt;BR /&gt;purpose  = "436640104,38763891420,"&lt;BR /&gt;roleID   = 4&lt;BR /&gt;routingInfo      = "3"&lt;BR /&gt;tranID    = "000210000002783264"&lt;BR /&gt;type     = "Request"&lt;BR /&gt;userID   = "C"&lt;BR /&gt;)&lt;BR /&gt;2008-01-16 09:10:39,104  INFO [http-8080]  (PaymentConnectionFactory.output) - getRef( q1 )&lt;BR /&gt;...&lt;BR /&gt;....&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;..&lt;BR /&gt;&lt;BR /&gt;Is there a way to write this output into this:&lt;BR /&gt;&lt;BR /&gt;accessID         = "Internet";sum   = 1;AccountID        = 0;consumerID       = "33333333333";consumerPIN      = "";currency         = "RAT";merchantID       = "C";name     = "Request";pin      = "";productID        = "Roam";purpose  = "436640104,38763891420,";roleID   = 4;routingInfo      = "3";tranID    = "000210000002783264";type     = "Request";userID   = "C"&lt;BR /&gt;&lt;BR /&gt;where:&lt;BR /&gt;FS=;&lt;BR /&gt;&lt;BR /&gt;parser should start with accessID filed and finish when it finds userID &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 16 Jan 2008 09:12:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-problem-shell-script/m-p/4130160#M727670</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2008-01-16T09:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: parsing problem..shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-problem-shell-script/m-p/4130161#M727671</link>
      <description>You can try with awk, I'd prefer perl.&lt;BR /&gt;General outline: Use a trigger variable, set trigger when the line starts with "accessID" and unset the trigger when the line starts with "userID".&lt;BR /&gt;Print only the lines when the trigger is set (mind the last one...)&lt;BR /&gt;With awk: Set the output field separator to ";", print a "\n" after each "userID"&lt;BR /&gt;&lt;BR /&gt;Have fun.</description>
      <pubDate>Wed, 16 Jan 2008 09:55:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-problem-shell-script/m-p/4130161#M727671</guid>
      <dc:creator>mschulz67</dc:creator>
      <dc:date>2008-01-16T09:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: parsing problem..shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-problem-shell-script/m-p/4130162#M727672</link>
      <description>In case U missunderstood I would like to have output:&lt;BR /&gt;&lt;BR /&gt;accessID = "Internet";sum = 1;AccountID = 0;consumerID = "33333333333";consumerPIN = "";currency = "RAT";merchantID = "C";name = "Request";pin = "";productID = "Roam";purpose = "436640104,38763891420,";roleID = 4;routingInfo = "3";tranID = "000210000002783264";type = "Request";userID = "C"&lt;BR /&gt;&lt;BR /&gt;where:&lt;BR /&gt;FS=;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;input is that file with lot of snippet of:&lt;BR /&gt;&lt;BR /&gt;accessID = "Internet"&lt;BR /&gt;accountType = payment.processing.AccountType(&lt;BR /&gt;value = 1&lt;BR /&gt;)&lt;BR /&gt;sum = 1&lt;BR /&gt;AccountID = 0&lt;BR /&gt;consumerID = "33333333333"&lt;BR /&gt;consumerPIN = ""&lt;BR /&gt;currency = "RAT"&lt;BR /&gt;merchantID = "C"&lt;BR /&gt;name = "Request"&lt;BR /&gt;pin = ""&lt;BR /&gt;productID = "Roam"&lt;BR /&gt;purpose = "436640104,38763891420,"&lt;BR /&gt;roleID = 4&lt;BR /&gt;routingInfo = "3"&lt;BR /&gt;tranID = "000210000002783264"&lt;BR /&gt;type = "Request"&lt;BR /&gt;userID = "C"&lt;BR /&gt;</description>
      <pubDate>Wed, 16 Jan 2008 11:09:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-problem-shell-script/m-p/4130162#M727672</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2008-01-16T11:09:29Z</dc:date>
    </item>
    <item>
      <title>Re: parsing problem..shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-problem-shell-script/m-p/4130163#M727673</link>
      <description>Try this awk line:&lt;BR /&gt;&lt;BR /&gt;$ awk '/^accessID/,/^userID/ {if (/^userID/) {print x $0; x=""} else { x = x $0 ";" }}' your-file&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Please specify what to do with the "accountType" entry, or rather, the other part of the request(accessID...) part.&lt;BR /&gt;&lt;BR /&gt;The example omits it, the specification does not.&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Wed, 16 Jan 2008 11:54:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-problem-shell-script/m-p/4130163#M727673</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2008-01-16T11:54:35Z</dc:date>
    </item>
    <item>
      <title>Re: parsing problem..shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-problem-shell-script/m-p/4130164#M727674</link>
      <description>that is pretty much that..except accountType should not be in parse result..just as U said. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;also all those 3 lines should NOT be in result:&lt;BR /&gt;&lt;BR /&gt;accountType = payment.processing.AccountType(&lt;BR /&gt;value = 1&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 16 Jan 2008 13:03:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-problem-shell-script/m-p/4130164#M727674</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2008-01-16T13:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: parsing problem..shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-problem-shell-script/m-p/4130165#M727675</link>
      <description>also...:(&lt;BR /&gt;can U help me with code explanation..I do not know purpose of this x variable..:(</description>
      <pubDate>Wed, 16 Jan 2008 13:06:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-problem-shell-script/m-p/4130165#M727675</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2008-01-16T13:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: parsing problem..shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-problem-shell-script/m-p/4130166#M727676</link>
      <description>In my first solution I use the awk 'range' selection "from one match untill the other": /one/,/other/&lt;BR /&gt;The 'x' variable is an accumulator where I add the pieces of string found plust seperator. Print and clean at end.&lt;BR /&gt;&lt;BR /&gt;The begin,end match can also be build by hand, using a flag set on first match, and cleared on last. Test flag all the time.&lt;BR /&gt;That's the 'f' in the next example.&lt;BR /&gt;The 'x' is still an accumulator, now cleared by assigning the first value.&lt;BR /&gt;&lt;BR /&gt;awk '/^userID/ {print x ";" $0; f=0} (f) {x = x ";" $0} /^accessID/ {x=$0;getline;getline;getline;f=1} ' your-file.&lt;BR /&gt;&lt;BR /&gt;In slow motion:&lt;BR /&gt;&lt;BR /&gt;awk '&lt;BR /&gt;/^userID/ # At the end...&lt;BR /&gt;{print x ";" $0; # print what we have in x sofar and add this line.&lt;BR /&gt;f=0} # no longer matching&lt;BR /&gt;&lt;BR /&gt;(f) # if matching&lt;BR /&gt;{x = x ";" $0} # add this chunk to accumulator x&lt;BR /&gt;&lt;BR /&gt;/^accessID/ # In the beginning&lt;BR /&gt;{x=$0;    # Start fresh accumulator&lt;BR /&gt;getline;getline;getline; # hardcoded skip&lt;BR /&gt;f=1} # start matching&lt;BR /&gt;&lt;BR /&gt;' your-file.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Wed, 16 Jan 2008 13:49:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-problem-shell-script/m-p/4130166#M727676</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2008-01-16T13:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: parsing problem..shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-problem-shell-script/m-p/4130167#M727677</link>
      <description>Thanks for help.. I sofar upgraded this script so now I created this output:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;myfile.txt:&lt;BR /&gt;....&lt;BR /&gt;..&lt;BR /&gt;784928|0002785283|Charge|SRoam&lt;BR /&gt;476431|0002785284|Charge|SRoam&lt;BR /&gt;844473|0012415890|Charge|SRoam&lt;BR /&gt;..&lt;BR /&gt;...&lt;BR /&gt;..&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In my second.txt file&lt;BR /&gt;&lt;BR /&gt;there is for filed $2 (myfile.txt) furher explanation:&lt;BR /&gt;&lt;BR /&gt;for example if I do    grep 0002785283 second.txt I get:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;2008-01-16 12:58:28,137 0002785283 FINISHED timeout = 1&lt;BR /&gt;2008-01-16 12:58:28,144 Result : 0002785283 res:1&lt;BR /&gt;&lt;BR /&gt;what I should get somehow get file:&lt;BR /&gt;&lt;BR /&gt;784928|0002785283|Charge|SRoam|2008-01-16 12:58:28,137 0002785283 FINISHED timeout = 1|2008-01-16 12:58:28,144 Result : 0002785283 res:1&lt;BR /&gt;&lt;BR /&gt;..Add those lines..&lt;BR /&gt;&lt;BR /&gt;so final file should have&lt;BR /&gt;&lt;BR /&gt;output.txt&lt;BR /&gt;&lt;BR /&gt;784928|0002785283|Charge|SRoam|2008-01-16 12:58:28,137 0002785283 FINISHED timeout = 1|2008-01-16 12:58:28,144 Result : 0002785283 res:1&lt;BR /&gt;476431|0002785284|Charge|SRoam|2007-01-16 11:38:28,137 0002785283 FINISHED timeout = 1|2008-01-16 12:58:28,144 Result : 0002785283 res:2&lt;BR /&gt;...&lt;BR /&gt;..&lt;BR /&gt;etc.&lt;BR /&gt;&lt;BR /&gt;Thank you in advance</description>
      <pubDate>Wed, 16 Jan 2008 14:44:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-problem-shell-script/m-p/4130167#M727677</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2008-01-16T14:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: parsing problem..shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-problem-shell-script/m-p/4130168#M727678</link>
      <description>Maybe I should write here what I did for this last post:&lt;BR /&gt;&lt;BR /&gt;while read line; do&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;        echo linija je $line&lt;BR /&gt;        #pattern1=$(nawk -F"|" '{ print $2 }' $line)&lt;BR /&gt;        pattern1=$(cut -d"|" -f2 $line)&lt;BR /&gt;        rest=$(grep $pattern1 second.txt )&lt;BR /&gt;        echo $line"|"$rest &amp;gt;&amp;gt; output.txt&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;done &amp;lt; myfile.txt&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;but error...this one:&lt;BR /&gt;&lt;BR /&gt;cut: cannot open 689133|4849844105|charge|cce&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;any help?</description>
      <pubDate>Thu, 17 Jan 2008 07:04:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-problem-shell-script/m-p/4130168#M727678</guid>
      <dc:creator>amonamon</dc:creator>
      <dc:date>2008-01-17T07:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: parsing problem..shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-problem-shell-script/m-p/4130169#M727679</link>
      <description>&lt;!--!*#--&gt;&amp;gt; I created this output: myfile.txt:&lt;BR /&gt;&lt;BR /&gt;For every record in this file you want to find something in second.txt file and join them?&lt;BR /&gt;&lt;BR /&gt;&amp;gt;I do grep 0002785283 second.txt I get:&lt;BR /&gt;2008-01-16 12:58:28,137 0002785283 FINISHED timeout = 1&lt;BR /&gt;2008-01-16 12:58:28,144 Result : 0002785283 res:1&lt;BR /&gt;&lt;BR /&gt;Is this one long line?  Or two lines that we need to combine?  (I assumed the latter and assumed only 2.)&lt;BR /&gt;&lt;BR /&gt;&amp;gt;so final file should have&lt;BR /&gt;&lt;BR /&gt;What is the connection from 0002785284 and the info from second.txt 0002785283, or is that a typo?&lt;BR /&gt;&lt;BR /&gt;Here is my script, it will be slow if second.txt is big:&lt;BR /&gt;awk -F"|" -v file2=second.txt '&lt;BR /&gt;{&lt;BR /&gt;cmd = "grep " $2 " " file2&lt;BR /&gt;cmd | getline save_2&lt;BR /&gt;cmd | getline save_3&lt;BR /&gt;print $0 "|" save_2 "|" save_3&lt;BR /&gt;} ' myfile.txt&lt;BR /&gt;&lt;BR /&gt;&amp;gt;but error...this one:&lt;BR /&gt;cut: cannot open 689133|4849844105|charge|cce&lt;BR /&gt; &lt;BR /&gt;cut(1) works on files not variables, so change to:&lt;BR /&gt;$ pattern1=$(echo $line | cut -d"|" -f2)</description>
      <pubDate>Thu, 17 Jan 2008 07:23:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-problem-shell-script/m-p/4130169#M727679</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-01-17T07:23:20Z</dc:date>
    </item>
    <item>
      <title>Re: parsing problem..shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-problem-shell-script/m-p/4130170#M727680</link>
      <description>Hi,&lt;BR /&gt;to mergethe merge you canb use the join command that's very powerful:&lt;BR /&gt;&lt;BR /&gt;1) tr -s '|' ' '&lt;MYFILE.TXT&gt;temp.txt&lt;BR /&gt;change the separtor in myfile.txt from '|' to space and save the result in temp.txt&lt;BR /&gt;&lt;BR /&gt;2) join -t " " -j1 2 -j2 3 -o 1.1,1.2,1.3,1.4,2.1,2.2,2.3,2.4,2.5,2.6,2.7 temp.txt second.txt&lt;BR /&gt;&lt;BR /&gt;merge teh two file by the key 2 in teh first file and key 3 in second file&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;i.e.:&lt;BR /&gt;&lt;BR /&gt;% cat myfile.txt &lt;BR /&gt;784928|0002785283|Charge|SRoam&lt;BR /&gt;476431|0002785284|Charge|SRoam&lt;BR /&gt;844473|0012415890|Charge|SRoam&lt;BR /&gt;&lt;BR /&gt;%cat second.txt &lt;BR /&gt;2008-01-16 12:58:28,137 0002785283 FINISHED timeout = 1&lt;BR /&gt;2008-01-16 12:58:28,144 Result : 0002785283 res:1&lt;BR /&gt;&lt;BR /&gt;%tr -s '|' ' '&lt;MYFILE.TXT&gt;temp.txt&lt;BR /&gt;%join -t " " -j1 2 -j2 3 -o 1.1,1.2,1.3,1.4,2.1,2.2,2.3,2.4,2.5,2.6,2.7 temp.txt second.txt&lt;BR /&gt;784928 0002785283 Charge SRoam 2008-01-16 12:58:28,137 0002785283 FINISHED timeout = 1&lt;BR /&gt;&lt;BR /&gt;type man join to understand all option used.&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Art&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/MYFILE.TXT&gt;&lt;/MYFILE.TXT&gt;</description>
      <pubDate>Thu, 17 Jan 2008 09:03:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-problem-shell-script/m-p/4130170#M727680</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2008-01-17T09:03:47Z</dc:date>
    </item>
  </channel>
</rss>

