I just uploaded a utility I wrote some time ago to handle this sort of thing on the command line. Look for "cmpcol" by graff in the code catacombs (new posting).

It probably doesn't do exactly what you want in your particular case, but it does tend to be very handy for a lot of things...

Here are some sample usages, given your left and right files as input:

# intersection (-i) of key fields: # (default delimiter is \s+, so use "-d ," here) $ cmpcol -i -d , left right 1 4 5 # print those records with the combined line # content from both files: $ cmpcol -i -d , -lb left right 1,a:<>:1,a 4,f:<>:4,g 5,h:<>:5,h # keys only in "left" file, which is "#1" on the # command line (-x1), showing full line (-l1): $ cmpcol -x1 -l1 -d , left right 2,b # lines with identical content (don't use # the comma delimiter in this case): $ cmpcol -i left right 1,a 5,h # all lines that are not identical (this # always shows which file contained each line): $ cmpcol -x left right 2,b <1 3,c <2 4,f <1 4,g <2 # and so on. I think the "usage" message is # the best part (at least I hope so): $ cmpcol Usage: cmpcol {-i|-u|-us|-x|-x1|-x2} [options] file1[:col#] file2[:col +#] Comparison modes: -i : produce intersection of file1[:col#] and file2[:col#] -u(s) : produce union (and identify sources) -x : produce exclusive-or, identifying sources -x1 (-x2) : produce items unique to file1 (or file2) Options: -l{1,2,b} : print whole lines from file1,file2 or both (default: pri +nt column) -g(v) ptn : grep (-v) -- only compare lines that (don't) contain /pt +n/ -c cchar : ignore material following cchar -d delim : use /delim/ as column separator (default is white-space) use "-d tab" for tab-delimited, "-d dot" for period-deli +mited file1 or file2 may be 'stdin' default ':col#' for comparison is first column from each file, which +is ':1'

In reply to Re: File comparison: not diff by graff
in thread File comparison: not diff by rschuler

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.