<?xml version="1.0" encoding="windows-1252"?>
<node id="36725" title="Detect common lines between two files, one liner from shell" created="2000-10-14 04:12:50" updated="2005-08-11 06:32:46">
<type id="1980">
snippet</type>
<author id="9073">
merlyn</author>
<data>
<field name="doctext">
</field>
<field name="snippetdesc">
A challenge was made in &lt;a href="news:comp.unix.shells"&gt;comp.unix.shells&lt;/a&gt;
for a short program to detect common lines in both &lt;tt&gt;fileA&lt;/tt&gt; and &lt;tt&gt;fileB&lt;/tt&gt;,
printing one copy of each of common lines.  Of course, this was a natural one-liner
in Perl, but I stumbled across a bizarre way which I though you might appreciate.</field>
<field name="snippetcode">
&lt;CODE&gt;
perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' fileA fileB &gt;output
&lt;/CODE&gt;</field>
</data>
</node>
