O wise ones - I'm having a brain freeze.

I have 6 text files of the format SHA-1<tab>7_hex_chars<newline> and each file has 9,000,000 lines. The 6 files are in the same order, with the SHA-1 being the key column of all the files. I can't slurp it all in, and I'm not wild about 6 open files at once, but that may be unavoidable.

I need to munge these together with the result of having six 7-hex-char strings on each line, the 6 values corresponding to the key SHA-1. I don't care if there is a separator, or what it is. Here's a very simple example:

file_1 123412341234etc 1000001 567856785678etc 5000001 ... file_2 123412341234etc 1000002 567856785678etc 5000002 ... file_3 123412341234etc 1000003 567856785678etc 5000003 ... munged output 1000001 1000002 1000003 ... 5000001 5000002 5000003 ...

I'm brain dead at the moment, if anyone can suggest a solution in perl (5.8 preferred) or a linux/BSD system tool, I'd appreciate it.


In reply to join on 6 huge files by dwhite20899

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.