Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If the files are not too big for memory, I would go with TLP's solution. If they are, you can modify it just a bit and print to a file as he suggests. Add this before the <code>while</code> (all untested, ymmv, caveat programmer, etc):</p> <pre><code>my $currentInFile = ""; my $currentOutFileHandle = ""; </code></pre> <p>And change the body of the <code>while</code> from the current <code>if-else</code> to</p> <pre><code>if ($currentInFile ne $ARG) { if (fileno($currentOutFileHandle)) { if (!close($currentOutFileHandle)) { # whatever you want to do if you can't close the previous output file } } my $newOutFile = $ARG . ".tagged"; if (!open($currentOutFileHandle, "&gt;", $newOutFile)) { # whatever you want to do if you can't open a new output file for writing } } if (...conditional from TLP...) { # add more zeroes if the files really are that large :) $lastkey = $1 . " " . sprintf("%0.10d", $.); } if (fileno($currentOutFileHandle)) { print $currentOutFileHandle $lastkey . "\t" . $line; } else { # whatever you want to do if $currentOutFileHandle's gone screwy } </code></pre> <p>Now you'll have a foo.log.tagged for each foo.log you fed it; the .tagged file contains exactly the contents of the original, but with "0xNNNNNNNN LLLLLLLLLL\t" (LLLLLLLLLL -> zero-padded line number) prepended to each line. <code>sort(1)</code> actually does a pretty good job of handling large data, though you'll want to look at the --temporary-directory argument if you think it will overflow /tmp with its temp files while chewing through the stuff you feed it. Something like this should get you started:</p> <pre><code>sort --output=/my/new/really.big.file --temporary-directory=/scratch/dir/on/roomy/partition *.tagged </code></pre> <p>Then trim away the tags if desired:</p> <pre><code>perl -pi -e 's/^[^\t]+\t//' /my/new/really.big.file </code></pre> <p>FWIW, I padded the line numbers to keep from having to worry about such things as line 10 sorting before line 2 if their hex keys were identical - since the hex numbers are the primary sort criterion, we can't just sort numerically.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload