Original poster here.

All is well. Used a combination of shell and perl to get the job done. Here's a rundown of the final solution:

  1. Open a new file for writing on another filesystem. Go through each input file and rewrite it to the new file using printf and int rand(1_000_000) to make lines with a random number at the start of each one.
  2. Use the *nix sort command to sort this file to a new one, writing to a different filesystem, and using the -T flag to put the temporary stuff on another filesystem. This took 45 minutes, but worked perfectly.
    (I tried combining 3 and 4 by having perl parse the large file and write to separate files, but it ran out of memory)
  3. Split the large sorted file up using "split -l 250000 sortedfile myfiles_"
  4. Have a perlscript open each file, remove the number and at the start of it, and write to the final finished files.

This worked fine - no memory problems, little I/O impact, and finished in a reasonable amount of time (< 4 hours). Thanks everyone!


In reply to Re: Strategy for randomizing large files via sysseek by Anonymous Monk
in thread Strategy for randomizing large files via sysseek by Anonymous Monk

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.