<?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: Common lines between two files in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/common-lines-between-two-files/m-p/2952029#M116205</link>
    <description># sdiff -o output -l teset1 teset2&lt;BR /&gt;&lt;BR /&gt;when you are prompted with %,&lt;BR /&gt;enter l.&lt;BR /&gt;&lt;BR /&gt;Then your matching lines will be in the output file.</description>
    <pubDate>Tue, 15 Apr 2003 19:30:21 GMT</pubDate>
    <dc:creator>Wilfred Chau_1</dc:creator>
    <dc:date>2003-04-15T19:30:21Z</dc:date>
    <item>
      <title>Common lines between two files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/common-lines-between-two-files/m-p/2952027#M116203</link>
      <description>Hi,&lt;BR /&gt;I have two files with some common lines between them.&lt;BR /&gt;How Can I extract these common lines and put them into another file? &lt;BR /&gt;&lt;BR /&gt;Are There some shell commands or scripts?&lt;BR /&gt;&lt;BR /&gt;Thank You!!!!</description>
      <pubDate>Tue, 15 Apr 2003 19:24:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/common-lines-between-two-files/m-p/2952027#M116203</guid>
      <dc:creator>Christian Aguilar Varga</dc:creator>
      <dc:date>2003-04-15T19:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: Common lines between two files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/common-lines-between-two-files/m-p/2952028#M116204</link>
      <description>use grep or egrep command.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Zafar</description>
      <pubDate>Tue, 15 Apr 2003 19:26:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/common-lines-between-two-files/m-p/2952028#M116204</guid>
      <dc:creator>Zafar A. Mohammed_1</dc:creator>
      <dc:date>2003-04-15T19:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: Common lines between two files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/common-lines-between-two-files/m-p/2952029#M116205</link>
      <description># sdiff -o output -l teset1 teset2&lt;BR /&gt;&lt;BR /&gt;when you are prompted with %,&lt;BR /&gt;enter l.&lt;BR /&gt;&lt;BR /&gt;Then your matching lines will be in the output file.</description>
      <pubDate>Tue, 15 Apr 2003 19:30:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/common-lines-between-two-files/m-p/2952029#M116205</guid>
      <dc:creator>Wilfred Chau_1</dc:creator>
      <dc:date>2003-04-15T19:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: Common lines between two files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/common-lines-between-two-files/m-p/2952030#M116206</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;See the man pages for 'comm' and 'diff'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 15 Apr 2003 19:30:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/common-lines-between-two-files/m-p/2952030#M116206</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-04-15T19:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: Common lines between two files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/common-lines-between-two-files/m-p/2952031#M116207</link>
      <description>Hi!&lt;BR /&gt;&lt;BR /&gt;See the man pages for diff&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;DR</description>
      <pubDate>Tue, 15 Apr 2003 19:33:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/common-lines-between-two-files/m-p/2952031#M116207</guid>
      <dc:creator>Dario_1</dc:creator>
      <dc:date>2003-04-15T19:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: Common lines between two files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/common-lines-between-two-files/m-p/2952032#M116208</link>
      <description>You can and should user the underestimated join command, it's not only very performant, but also very powerful.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;file1="file1"&lt;BR /&gt;file2="file2"&lt;BR /&gt;&lt;BR /&gt;sort1="${file1}.sort"&lt;BR /&gt;sort2="${file2}.sort"&lt;BR /&gt;&lt;BR /&gt;sort ${file1} &amp;gt; ${sort1}&lt;BR /&gt;sort ${file2} &amp;gt; ${sort2}&lt;BR /&gt;&lt;BR /&gt;join ${sort1} ${sort2}&lt;BR /&gt;&lt;BR /&gt;rm -f ${sort1} ${sort2} &lt;BR /&gt;&lt;BR /&gt;hecou</description>
      <pubDate>Wed, 16 Apr 2003 07:50:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/common-lines-between-two-files/m-p/2952032#M116208</guid>
      <dc:creator>Systeemingenieurs Infoc</dc:creator>
      <dc:date>2003-04-16T07:50:56Z</dc:date>
    </item>
    <item>
      <title>Re: Common lines between two files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/common-lines-between-two-files/m-p/2952033#M116209</link>
      <description>It all very much depends on how these `common' lines appear in the files.&lt;BR /&gt;&lt;BR /&gt;If both files are sorted, 'comm' is *the* way to go:&lt;BR /&gt;&lt;BR /&gt;# comm -12 file1 file2 &amp;gt;common&lt;BR /&gt;# comm -13 file1 file2 &amp;gt;onlyin2&lt;BR /&gt;# comm -23 file1 file2 &amp;gt;onlyin1&lt;BR /&gt;&lt;BR /&gt;Then of course you have the question "are all lines unique?", and do you want unique lines squeezed? If lines are distributed unsorted and non-uniquely, and you want to see all lines:&lt;BR /&gt;&lt;BR /&gt;# fgrep -f file1 file2&lt;BR /&gt;&lt;BR /&gt;which has the disadvantage that if file1 contains short lines that might be occuring as part of files2's lines, you get too much. With GNU grep you can do better:&lt;BR /&gt;&lt;BR /&gt;# fgrep -x -f file1 file2&lt;BR /&gt;&lt;BR /&gt;And to squeeze the output, filter the dups:&lt;BR /&gt;&lt;BR /&gt;# fgrep -x -f file1 file2 | uniq&lt;BR /&gt;&lt;BR /&gt;Or if the sequence is not important:&lt;BR /&gt;&lt;BR /&gt;# fgrep -x -f file1 file2 | sort -u&lt;BR /&gt;&lt;BR /&gt;Or alternatively&lt;BR /&gt;&lt;BR /&gt;# perl -e'$f2=pop;while(&amp;lt;&amp;gt;){$x{$_}++};@ARGV=($f2);while(&amp;lt;&amp;gt;){exists$x{$_}and print' file1 file2&lt;BR /&gt;&lt;BR /&gt;Enjoy, have FUN! H.Merijn</description>
      <pubDate>Wed, 16 Apr 2003 08:18:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/common-lines-between-two-files/m-p/2952033#M116209</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2003-04-16T08:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: Common lines between two files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/common-lines-between-two-files/m-p/2952034#M116210</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;you can use sdiff for this.&lt;BR /&gt;&lt;BR /&gt; -o output   &lt;BR /&gt;Use the next argument, output, as the name of a third file that is created as a user-controlled merging of file1 and file2.  Identical lines of file1 and file2 are copied to output.  Sets of differences, as        produced by diff(1), are printed; &lt;BR /&gt;&lt;BR /&gt;where a set of differences share a common gutter character.  After printing each set of differences, sdiff prompts the user with a % and waits for user-typed commands. &lt;BR /&gt;&lt;BR /&gt;If you give q, it will quit and the common lines will be present in file "output".&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;VJ</description>
      <pubDate>Wed, 16 Apr 2003 09:46:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/common-lines-between-two-files/m-p/2952034#M116210</guid>
      <dc:creator>vasundhara</dc:creator>
      <dc:date>2003-04-16T09:46:08Z</dc:date>
    </item>
  </channel>
</rss>

