<?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: Comparing two files and extract data in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/comparing-two-files-and-extract-data/m-p/3869250#M34846</link>
    <description>(I don't know where that last line came from)&lt;BR /&gt;Phil</description>
    <pubDate>Mon, 25 Sep 2006 19:16:17 GMT</pubDate>
    <dc:creator>Phil.Howell</dc:creator>
    <dc:date>2006-09-25T19:16:17Z</dc:date>
    <item>
      <title>Comparing two files and extract data</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/comparing-two-files-and-extract-data/m-p/3869246#M34842</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Please can someone help me. I really stuck! I have two text files that I want to compare. If the same data is in both, I want to extract the data.&lt;BR /&gt;     &lt;BR /&gt;I want to following output as the data is in both files:-&lt;BR /&gt;&lt;BR /&gt;SEE ATTACHED FILE&lt;BR /&gt;&lt;BR /&gt;Hope someone can help me!!!&lt;BR /&gt;Thank you,&lt;BR /&gt;Ian</description>
      <pubDate>Mon, 25 Sep 2006 14:54:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/comparing-two-files-and-extract-data/m-p/3869246#M34842</guid>
      <dc:creator>Ian McWhirter</dc:creator>
      <dc:date>2006-09-25T14:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two files and extract data</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/comparing-two-files-and-extract-data/m-p/3869247#M34843</link>
      <description>&lt;!--!*#--&gt;What you're looking for is the intersection of the two files, i.e. a file containing only those records that are contained in both files.&lt;BR /&gt;&lt;BR /&gt;Unfortunatly, DCL doesn't have a built-in function or command that does that.&lt;BR /&gt;&lt;BR /&gt;Here's a "quick &amp;amp; dirty" command procedure I just wrote &amp;amp; tested really quickly. There's not much error checking, so you probably don't want to use it "as is".&lt;BR /&gt;&lt;BR /&gt;Ken&lt;BR /&gt;&lt;BR /&gt;intersection.com&lt;BR /&gt;&lt;BR /&gt;$ open/read f1 'p1'.txt&lt;BR /&gt;$ copy nl: 'p3'.txt&lt;BR /&gt;$ open/app out 'p3'.txt&lt;BR /&gt;$ read f1 line&lt;BR /&gt;$ write out line ! takes care of the header line&lt;BR /&gt;$rl:&lt;BR /&gt;$ read/end=done f1 line&lt;BR /&gt;$ sear/noout 'p2'.txt "''line'"&lt;BR /&gt;$ if $status .eqs. "%X00000001" then write/sym out line&lt;BR /&gt;$ goto rl&lt;BR /&gt;$done:&lt;BR /&gt;$ close out&lt;BR /&gt;$ close f1&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Sep 2006 17:05:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/comparing-two-files-and-extract-data/m-p/3869247#M34843</guid>
      <dc:creator>Ken Robinson</dc:creator>
      <dc:date>2006-09-25T17:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two files and extract data</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/comparing-two-files-and-extract-data/m-p/3869248#M34844</link>
      <description>&lt;!--!*#--&gt;It sounds as if you may need to write a real&lt;BR /&gt;program.&lt;BR /&gt;&lt;BR /&gt;If you have (or can get) a copy of GNU&lt;BR /&gt;"diff" (part of the GNU Diffutils) package,&lt;BR /&gt;then you might get close using something&lt;BR /&gt;like this:&lt;BR /&gt;&lt;BR /&gt;pipe gdiff -y V1.TXT V2.TXT | search /match = nor sys$input "&amp;lt;", "&amp;gt;"&lt;BR /&gt;&lt;BR /&gt;For example:&lt;BR /&gt;&lt;BR /&gt;alp $ pipe gdiff -y V1.TXT V2.TXT | search /match = nor sys$input "&amp;lt;", "&amp;gt;"&lt;BR /&gt;BIN      ITEM                                                   BIN      ITEM&lt;BR /&gt;02R_346  11012447                                               02R_346  11012447&lt;BR /&gt;02S_234  00125774                                               02S_234  00125774&lt;BR /&gt;03B_233  99002567                                               03B_233  99002567&lt;BR /&gt;04P_459  00389256                                               04P_459  00389256&lt;BR /&gt;&lt;BR /&gt;"gdiff -y" does "Output in two columns", and&lt;BR /&gt;you get lines with "&amp;lt;" or "&amp;gt;" if a line&lt;BR /&gt;appears in only one file, but lines which&lt;BR /&gt;appear in both files will appears twice per&lt;BR /&gt;line in the output.  A little DCL&lt;BR /&gt;post-processing could cure that.&lt;BR /&gt;&lt;BR /&gt;For large files, it may help to sort the&lt;BR /&gt;input files before sending them through&lt;BR /&gt;"diff".&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.gnu.org/software/diffutils/" target="_blank"&gt;http://www.gnu.org/software/diffutils/&lt;/A&gt;</description>
      <pubDate>Mon, 25 Sep 2006 17:06:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/comparing-two-files-and-extract-data/m-p/3869248#M34844</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2006-09-25T17:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two files and extract data</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/comparing-two-files-and-extract-data/m-p/3869249#M34845</link>
      <description>try this&lt;BR /&gt;Phil&lt;BR /&gt;&lt;BR /&gt;$copy file1.txt files.txt&lt;BR /&gt;$append file2.txt files.txt&lt;BR /&gt;$sort files.txt sorted.txt&lt;BR /&gt;$sort/nodup files.txt nodup.txt&lt;BR /&gt;$diff/para/match=1 sorted.txt nodup.txt&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;copy file2.txt</description>
      <pubDate>Mon, 25 Sep 2006 19:14:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/comparing-two-files-and-extract-data/m-p/3869249#M34845</guid>
      <dc:creator>Phil.Howell</dc:creator>
      <dc:date>2006-09-25T19:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two files and extract data</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/comparing-two-files-and-extract-data/m-p/3869250#M34846</link>
      <description>(I don't know where that last line came from)&lt;BR /&gt;Phil</description>
      <pubDate>Mon, 25 Sep 2006 19:16:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/comparing-two-files-and-extract-data/m-p/3869250#M34846</guid>
      <dc:creator>Phil.Howell</dc:creator>
      <dc:date>2006-09-25T19:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two files and extract data</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/comparing-two-files-and-extract-data/m-p/3869251#M34847</link>
      <description>Soooo many ways....&lt;BR /&gt;The easiest, once you have GNV installed:&lt;BR /&gt;&lt;BR /&gt;$ mcr USERS:[SYS0.SYSCOMMON.GNV.bin]GREP -f file2.tmp file1.tmp&lt;BR /&gt;&lt;BR /&gt;The 'native way' albeit with some noise:&lt;BR /&gt;&lt;BR /&gt;$ conv/fdl="fil; org ind; rec; form fix; size 18; area 0; buc 60; key 0; seg0_l 18"/fast/excep=xxx.tmp/sort/pad/tru fi&lt;BR /&gt;le1.tmp,file2.tmp tmp.tmp&lt;BR /&gt;&lt;BR /&gt;pre 8.3 that would be:&lt;BR /&gt;&lt;BR /&gt;$ conv/fdl=sys$input/fast/excep=both.txt/sort/pad/trun &lt;BR /&gt;file; org ind; rec; form fix; size 18; area 0; buc 60; key 0; seg0_l 18"&lt;BR /&gt;file1.tmp,file2.tmp tmp.tmp&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;With perl, this script will do the job:&lt;BR /&gt;&lt;BR /&gt;----- both.pl -------&lt;BR /&gt;$file = shift @ARGV;&lt;BR /&gt;open FILE, "&amp;lt;$file" or die "Could not open $file";&lt;BR /&gt;while (&lt;FILE&gt;) {&lt;BR /&gt;   $seen{$_}++;&lt;BR /&gt;}&lt;BR /&gt;$file = shift @ARGV;&lt;BR /&gt;open FILE, "&amp;lt;$file" or die "Could not open $file";&lt;BR /&gt;while (&lt;FILE&gt;) {&lt;BR /&gt;   print if $seen{$_}++;&lt;BR /&gt;}&lt;BR /&gt;$ perl both.pl file2.txt file1.txt&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;And finally with DCL:&lt;BR /&gt;&lt;BR /&gt;------------- both.com --------&lt;BR /&gt;$open/read file 'p1&lt;BR /&gt;$loop1:&lt;BR /&gt;$read/end=file2 file record&lt;BR /&gt;$x = f$edit(record,"COLLAPSE")&lt;BR /&gt;$x'x = 1&lt;BR /&gt;$goto loop1&lt;BR /&gt;$&lt;BR /&gt;$file2:&lt;BR /&gt;$close file&lt;BR /&gt;$open/read file 'p2&lt;BR /&gt;$loop2:&lt;BR /&gt;$read/end=done file record&lt;BR /&gt;$x = f$edit(record,"COLLAPSE")&lt;BR /&gt;$if f$type(x'x).eqs."INTEGER" then write sys$output record&lt;BR /&gt;$goto loop2&lt;BR /&gt;$&lt;BR /&gt;$done:&lt;BR /&gt;$close file&lt;BR /&gt;&lt;BR /&gt;$@both file2.tmp file1.tmp&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;/FILE&gt;&lt;/FILE&gt;</description>
      <pubDate>Mon, 25 Sep 2006 20:11:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/comparing-two-files-and-extract-data/m-p/3869251#M34847</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-09-25T20:11:56Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two files and extract data</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/comparing-two-files-and-extract-data/m-p/3869252#M34848</link>
      <description>&lt;!--!*#--&gt;And yet another lame method:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; $copy file1.txt files.txt&lt;BR /&gt;&amp;gt; $append file2.txt files.txt&lt;BR /&gt;&lt;BR /&gt;copy file1.txt, file2.txt files.txt&lt;BR /&gt;&lt;BR /&gt;sort files.txt sorted.txt&lt;BR /&gt;sort /nodup files.txt nodup.txt&lt;BR /&gt;&lt;BR /&gt;pipe diff /match = 1 /merged = 0 /nonumber -&lt;BR /&gt;sorted.txt nodup.txt | search /match = nor -&lt;BR /&gt;sys$input "******", "Number of difference", -&lt;BR /&gt;"DIFFERENCES ", ";"&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Sep 2006 20:18:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/comparing-two-files-and-extract-data/m-p/3869252#M34848</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2006-09-25T20:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two files and extract data</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/comparing-two-files-and-extract-data/m-p/3869253#M34849</link>
      <description>Ian,&lt;BR /&gt;&lt;BR /&gt;I would definitely agree with Hein, using CONVERT is the easiest way to do it.&lt;BR /&gt;&lt;BR /&gt;- Bob Gezelter, &lt;A href="http://www.rlgsc.com" target="_blank"&gt;http://www.rlgsc.com&lt;/A&gt;</description>
      <pubDate>Tue, 26 Sep 2006 05:05:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/comparing-two-files-and-extract-data/m-p/3869253#M34849</guid>
      <dc:creator>Robert Gezelter</dc:creator>
      <dc:date>2006-09-26T05:05:09Z</dc:date>
    </item>
  </channel>
</rss>

