<?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 scripting question: how to merge two file based on common strings? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-how-to-merge-two-file-based-on-common-strings/m-p/4381452#M348664</link>
    <description>Hello scripting masters,&lt;BR /&gt;I have two file , and want to make it one , after comparing a common field:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;file1&lt;BR /&gt;######&lt;BR /&gt;mm00  9900&lt;BR /&gt;nn00  8811&lt;BR /&gt;oo00  7722&lt;BR /&gt;pp00  663x&lt;BR /&gt;qq00  5544&lt;BR /&gt;rr00  4433&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;file2&lt;BR /&gt;##########&lt;BR /&gt;mm00  9:0:1&lt;BR /&gt;nn00  8:0:2&lt;BR /&gt;oo00  7:0:3&lt;BR /&gt;pp00  6:0:4&lt;BR /&gt;qq00  5:0:x&lt;BR /&gt;rr00  4:0:t&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Output should be:&lt;BR /&gt;mm00  9900 9:0:1&lt;BR /&gt;nn00  8811 8:0:2&lt;BR /&gt;oo00  7722 7:0:3&lt;BR /&gt;pp00  663x 6:0:4&lt;BR /&gt;qq00  5544 5:0:x&lt;BR /&gt;rr00  4433 4:0:t&lt;BR /&gt;###################&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks in advance..&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 17 Mar 2009 16:22:40 GMT</pubDate>
    <dc:creator>rveri</dc:creator>
    <dc:date>2009-03-17T16:22:40Z</dc:date>
    <item>
      <title>scripting question: how to merge two file based on common strings?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-how-to-merge-two-file-based-on-common-strings/m-p/4381452#M348664</link>
      <description>Hello scripting masters,&lt;BR /&gt;I have two file , and want to make it one , after comparing a common field:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;file1&lt;BR /&gt;######&lt;BR /&gt;mm00  9900&lt;BR /&gt;nn00  8811&lt;BR /&gt;oo00  7722&lt;BR /&gt;pp00  663x&lt;BR /&gt;qq00  5544&lt;BR /&gt;rr00  4433&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;file2&lt;BR /&gt;##########&lt;BR /&gt;mm00  9:0:1&lt;BR /&gt;nn00  8:0:2&lt;BR /&gt;oo00  7:0:3&lt;BR /&gt;pp00  6:0:4&lt;BR /&gt;qq00  5:0:x&lt;BR /&gt;rr00  4:0:t&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Output should be:&lt;BR /&gt;mm00  9900 9:0:1&lt;BR /&gt;nn00  8811 8:0:2&lt;BR /&gt;oo00  7722 7:0:3&lt;BR /&gt;pp00  663x 6:0:4&lt;BR /&gt;qq00  5544 5:0:x&lt;BR /&gt;rr00  4433 4:0:t&lt;BR /&gt;###################&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks in advance..&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Mar 2009 16:22:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-how-to-merge-two-file-based-on-common-strings/m-p/4381452#M348664</guid>
      <dc:creator>rveri</dc:creator>
      <dc:date>2009-03-17T16:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question: how to merge two file based on common strings?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-how-to-merge-two-file-based-on-common-strings/m-p/4381453#M348665</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;# comm&lt;BR /&gt;&lt;BR /&gt;...see the manpages.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 17 Mar 2009 16:33:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-how-to-merge-two-file-based-on-common-strings/m-p/4381453#M348665</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-03-17T16:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question: how to merge two file based on common strings?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-how-to-merge-two-file-based-on-common-strings/m-p/4381454#M348666</link>
      <description>If you are really asking the scripting question of how to nest file reads in shell, use something like this:&lt;BR /&gt;&lt;BR /&gt;cat f2 |&amp;amp;&lt;BR /&gt;while read A B&lt;BR /&gt;do&lt;BR /&gt;read -p C D&lt;BR /&gt;if [[ ${A} != ${C} ]]&lt;BR /&gt;then&lt;BR /&gt;   echo "ERROR:  Files out of sync ($A != $C)"&lt;BR /&gt;else&lt;BR /&gt;   echo "$A $B $D"&lt;BR /&gt;fi&lt;BR /&gt;done &amp;lt; f1&lt;BR /&gt;mm00 9900 9:0:1&lt;BR /&gt;nn00 8811 8:0:2&lt;BR /&gt;oo00 7722 7:0:3&lt;BR /&gt;pp00 663x 6:0:4&lt;BR /&gt;qq00 5544 5:0:x&lt;BR /&gt;rr00 4433 4:0:t&lt;BR /&gt;&lt;BR /&gt;The comm(1) command does not do partial line pattern matching and is not really what you are looking for.&lt;BR /&gt;&lt;BR /&gt;The above script assumes sort order and a 1 to 1 match for the lines.  This can obviously be made much smarter.</description>
      <pubDate>Tue, 17 Mar 2009 16:44:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-how-to-merge-two-file-based-on-common-strings/m-p/4381454#M348666</guid>
      <dc:creator>Bob E Campbell</dc:creator>
      <dc:date>2009-03-17T16:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question: how to merge two file based on common strings?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-how-to-merge-two-file-based-on-common-strings/m-p/4381455#M348667</link>
      <description>OK, if I take away the assumptions of sort order and 1 to 1 mapping I come up with:&lt;BR /&gt;&lt;BR /&gt;while read A B&lt;BR /&gt;do&lt;BR /&gt;  Matches="$(grep -e "^${A}" f2)"&lt;BR /&gt;  if [[ -z "${Matches}" ]]&lt;BR /&gt;  then&lt;BR /&gt;    echo "$A $B MISSING-DATA"&lt;BR /&gt;  else&lt;BR /&gt;    echo "${Matches}" |\&lt;BR /&gt;    while read C D&lt;BR /&gt;    do&lt;BR /&gt;      echo "$A $B $D"&lt;BR /&gt;    done&lt;BR /&gt;  fi&lt;BR /&gt;done &amp;lt; f1&lt;BR /&gt;&lt;BR /&gt;while read C D&lt;BR /&gt;do&lt;BR /&gt;  grep -sqe "^${C}" f1&lt;BR /&gt;  if [[ $? -ne 0 ]]&lt;BR /&gt;  then&lt;BR /&gt;    echo "$C MISSING-DATA $D"&lt;BR /&gt;  fi&lt;BR /&gt;done &amp;lt; f2&lt;BR /&gt;&lt;BR /&gt;gives the result (with edited files)&lt;BR /&gt;&lt;BR /&gt;mm00 9900 9:0:1&lt;BR /&gt;nn00 8811 8:0:2&lt;BR /&gt;oo00 7722 7:0:3&lt;BR /&gt;pp00 663x 6:0:4&lt;BR /&gt;pp00 663x 6:5:3&lt;BR /&gt;pp00 663x 5:0:2&lt;BR /&gt;qq00 5544 5:0:x&lt;BR /&gt;rr00 4433 4:0:t&lt;BR /&gt;zz00 1234 MISSING-DATA&lt;BR /&gt;xx00 MISSING-DATA 3:1:7&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Really just filling time before lunch...  I should be doing many other things....</description>
      <pubDate>Tue, 17 Mar 2009 17:03:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-how-to-merge-two-file-based-on-common-strings/m-p/4381455#M348667</guid>
      <dc:creator>Bob E Campbell</dc:creator>
      <dc:date>2009-03-17T17:03:10Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question: how to merge two file based on common strings?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-how-to-merge-two-file-based-on-common-strings/m-p/4381456#M348668</link>
      <description>&lt;BR /&gt;I'm sure JRF meant 'join', not comm'.&lt;BR /&gt;&lt;BR /&gt;That should work, IF the files are sorted ALPHA. Watch out for free-format numbers.&lt;BR /&gt;&lt;BR /&gt;Hein.</description>
      <pubDate>Tue, 17 Mar 2009 18:18:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-how-to-merge-two-file-based-on-common-strings/m-p/4381456#M348668</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2009-03-17T18:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question: how to merge two file based on common strings?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-how-to-merge-two-file-based-on-common-strings/m-p/4381457#M348669</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;here is the example&lt;BR /&gt;[root@rspc521 suraj]# cat 1&lt;BR /&gt;nn00 8811&lt;BR /&gt;oo00 7722&lt;BR /&gt;pp00 663x&lt;BR /&gt;qq00 5544&lt;BR /&gt;rr00 4433&lt;BR /&gt;&lt;BR /&gt;[root@rspc521 suraj]# cat 2&lt;BR /&gt;mm00 9:0:1&lt;BR /&gt;nn00 8:0:2&lt;BR /&gt;oo00 7:0:3&lt;BR /&gt;pp00 6:0:4&lt;BR /&gt;qq00 5:0:x&lt;BR /&gt;rr00 4:0:t&lt;BR /&gt;&lt;BR /&gt;[root@rspc521 suraj]# join 1 2&lt;BR /&gt;nn00 8811 8:0:2&lt;BR /&gt;oo00 7722 7:0:3&lt;BR /&gt;pp00 663x 6:0:4&lt;BR /&gt;qq00 5544 5:0:x&lt;BR /&gt;rr00 4433 4:0:t&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Suraj</description>
      <pubDate>Wed, 18 Mar 2009 03:51:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-how-to-merge-two-file-based-on-common-strings/m-p/4381457#M348669</guid>
      <dc:creator>Suraj K Sankari</dc:creator>
      <dc:date>2009-03-18T03:51:19Z</dc:date>
    </item>
  </channel>
</rss>

