If you have two plain text files where one file looks like this:
key1 key3 key4 key6 ...
and the other file looks like this:
key2 key3 key4 key5 ...
then you might try downloading this script that I posted here under "Code/Utilities". To find the keys that are common to both files, the command line is:
cmpcol -i file1 file2
To find the union:
cmpcol -u file1 file2
To find the keys that are unique to file1 (or file2):
cmpcol -x1 file1 file2 # what's uniq to file1 cmpcol -x2 file1 file2 # what's uniq to file2 cmpcol -x file1 file2 # all uniq items, tagged by source -- i.e.: key1 <1 key2 <2 key5 <2 key6 <1
It also handles multi-column data (use "file1:4" to use column 4 of file1 as the key field in that file), and supports perl regex field delimiters (e.g. -d '[\s:;,.]+' to split each line of each file at any combination of whitespace and/or punctuation).

It has more bells and whistles... I hope it helps.


In reply to Re: Finding duplicate keys by graff
in thread Finding duplicate keys by Wally Hartshorn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.