<?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 Compare file in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/compare-file/m-p/5564099#M640348</link>
    <description>&lt;P&gt;I have two files as below , I would like to compare the content&lt;/P&gt;&lt;P&gt;file 1&lt;BR /&gt;======&lt;BR /&gt;aaa.txt&lt;BR /&gt;111&lt;BR /&gt;222&lt;BR /&gt;bbb.txt&lt;BR /&gt;333&lt;BR /&gt;ccc.txt&lt;BR /&gt;ddd.txt&lt;BR /&gt;eee.txt&lt;/P&gt;&lt;P&gt;file 2&lt;BR /&gt;======&lt;BR /&gt;aaa.txt&lt;BR /&gt;444&lt;BR /&gt;bbb.txt&lt;BR /&gt;555&lt;BR /&gt;ccc.txt&lt;BR /&gt;ddd.txt&lt;BR /&gt;eee.txt&lt;/P&gt;&lt;P&gt;Result&lt;BR /&gt;======&lt;BR /&gt;aaa.txt&lt;BR /&gt;111&lt;BR /&gt;222&lt;BR /&gt;aaa.txt&lt;BR /&gt;444&lt;BR /&gt;bbb.txt&lt;BR /&gt;333&lt;BR /&gt;bbb.txt&lt;BR /&gt;555&lt;BR /&gt;ccc.txt&lt;BR /&gt;ccc.txt&lt;BR /&gt;ddd.txt&lt;BR /&gt;ddd.txt&lt;BR /&gt;eee.txt&lt;BR /&gt;eee.txt&lt;/P&gt;&lt;P&gt;Some content is the same ( eg. aaa.txt , bbb.txt , ccc.txt , ddd.txt , eee.txt ) , I would like to list its content by a condition to a file as the above result file - if the line is the same then output its next line(s) to the result file ,&lt;/P&gt;&lt;P&gt;can advise what can i do ?&lt;/P&gt;&lt;P&gt;thanks.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Feb 2012 01:42:16 GMT</pubDate>
    <dc:creator>Intothenewworld</dc:creator>
    <dc:date>2012-02-27T01:42:16Z</dc:date>
    <item>
      <title>Compare file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/compare-file/m-p/5564099#M640348</link>
      <description>&lt;P&gt;I have two files as below , I would like to compare the content&lt;/P&gt;&lt;P&gt;file 1&lt;BR /&gt;======&lt;BR /&gt;aaa.txt&lt;BR /&gt;111&lt;BR /&gt;222&lt;BR /&gt;bbb.txt&lt;BR /&gt;333&lt;BR /&gt;ccc.txt&lt;BR /&gt;ddd.txt&lt;BR /&gt;eee.txt&lt;/P&gt;&lt;P&gt;file 2&lt;BR /&gt;======&lt;BR /&gt;aaa.txt&lt;BR /&gt;444&lt;BR /&gt;bbb.txt&lt;BR /&gt;555&lt;BR /&gt;ccc.txt&lt;BR /&gt;ddd.txt&lt;BR /&gt;eee.txt&lt;/P&gt;&lt;P&gt;Result&lt;BR /&gt;======&lt;BR /&gt;aaa.txt&lt;BR /&gt;111&lt;BR /&gt;222&lt;BR /&gt;aaa.txt&lt;BR /&gt;444&lt;BR /&gt;bbb.txt&lt;BR /&gt;333&lt;BR /&gt;bbb.txt&lt;BR /&gt;555&lt;BR /&gt;ccc.txt&lt;BR /&gt;ccc.txt&lt;BR /&gt;ddd.txt&lt;BR /&gt;ddd.txt&lt;BR /&gt;eee.txt&lt;BR /&gt;eee.txt&lt;/P&gt;&lt;P&gt;Some content is the same ( eg. aaa.txt , bbb.txt , ccc.txt , ddd.txt , eee.txt ) , I would like to list its content by a condition to a file as the above result file - if the line is the same then output its next line(s) to the result file ,&lt;/P&gt;&lt;P&gt;can advise what can i do ?&lt;/P&gt;&lt;P&gt;thanks.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2012 01:42:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/compare-file/m-p/5564099#M640348</guid>
      <dc:creator>Intothenewworld</dc:creator>
      <dc:date>2012-02-27T01:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: Compare file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/compare-file/m-p/5564247#M640349</link>
      <description>&lt;P&gt;There is not really enough information for a good solution&lt;/P&gt;&lt;P&gt;0) Always just 2 input files, or more?&lt;/P&gt;&lt;P&gt;1) what pattern can be used to recognize 'some content is the same'&amp;nbsp;&lt;/P&gt;&lt;P&gt;in the example: ".txt$". But what about for real? line starts with special character or word? NOT a number? Extra long, extra short?&lt;/P&gt;&lt;P&gt;2) is each match line garantueed to be present?&lt;/P&gt;&lt;P&gt;If not, How to sync back up on missing match line?&amp;nbsp;&lt;/P&gt;&lt;P&gt;3) working with megabytes of data or gigabytes?&lt;/P&gt;&lt;P&gt;When working with megabytes all data can be kept in memory,&lt;/P&gt;&lt;P&gt;When working with gigabytes the solution with need to read the two files in near lock-step&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a solution using memory....&lt;/P&gt;&lt;P&gt;&amp;gt; variable k is the 'current key' based on matching the 'same content trigger'&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; array x gets an entry per key, concatenating the current line and a new-line char for each line in all input&lt;/P&gt;&lt;P&gt;&amp;gt; array y gets an entry per unique key, ordered by number of arrival to keep printed in order of input.&lt;/P&gt;&lt;P&gt;&amp;gt; at the end for each entry in Y print the content of X, which is all lines for a given 'section'/key.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;$ awk '/.txt$/{k=$0; if (!( k in x)) y[i++]=k } {x[k] = x[k] $0 "\n"} END{for (j=0;j&amp;lt;i;j++) print x[y[j]]} ' file1 file2&lt;BR /&gt;aaa.txt&lt;BR /&gt;111&lt;BR /&gt;222&lt;BR /&gt;aaa.txt&lt;BR /&gt;444&lt;/P&gt;&lt;P&gt;bbb.txt&lt;BR /&gt;333&lt;BR /&gt;bbb.txt&lt;BR /&gt;555&lt;/P&gt;&lt;P&gt;ccc.txt&lt;BR /&gt;ccc.txt&lt;/P&gt;&lt;P&gt;ddd.txt&lt;BR /&gt;ddd.txt&lt;/P&gt;&lt;P&gt;eee.txt&lt;BR /&gt;eee.txt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Good luck!&lt;/P&gt;&lt;P&gt;Hein.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2012 05:18:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/compare-file/m-p/5564247#M640349</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2012-02-27T05:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: Compare file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/compare-file/m-p/5565305#M640350</link>
      <description>&lt;P&gt;&amp;gt;I would like to list its content by a condition to a file as the above result file -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It appears you are trying to merge the two files?&amp;nbsp; Where the content in file 2 is added to the end of the same section in file 1?&lt;/P&gt;&lt;P&gt;Are the two files sorted by their *.txt entries?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2012 16:54:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/compare-file/m-p/5565305#M640350</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2012-02-27T16:54:51Z</dc:date>
    </item>
  </channel>
</rss>

