One of our databases started spewing an enormous log file and non technical person were asked to look through it. Because the size of the file diddn't allow them to open it of their workstation, I was asked to split the files in chunks of 100MB.
Because I didn't find the pattern for one elementary log, I went for the brutal strict solution:
Split into 100MB files, whether the split is to be made at the end of a log entry or not.
I came up with the following perl script, and I does the job.
#!/usr/bin/perl
use strict;
use warnings;
die "usage : $0 <logfile> <chunk size in MB>" unless ( $ARGV[0] && $ARGV[1] );
my $chunks = (-s $ARGV[0]) / 1024 / 1024 / $ARGV[1];
my $chunk = 1;
while ( $chunk <= $chunks ) {
my $dest = "$ARGV[0]-$chunk";
my $skip = $ARGV[1] * $chunk;
my @dd = ("dd", "if=$ARGV[0]", "of=$dest", "bs=1M", "count=$ARGV[1]", "skip=$skip");
print @dd, "\n";
system(@dd) == 0
or die "system @dd failed: $?";
$chunk++;
}