I used the script below, and added some things , well, a friend of mine came up with it:
my $size=(stat('/usr/messages.sorted'))[7]; my $chunksize = 10 * 1024 *1024 ; # mb my $split_into = $size/$chunksize;
That makes every chunk 10megabyte. So i don't have to guess it then :-)
Again: Thanks for the pointers and the help!!
Cheers
WC Jones wrote:
set size arguments set input file set output file
open the file read the content print line of the content to $output file check size of $output file continue if not to big yet else check which files already live in the target directory (.1 .2 .3 .4 .5 etc) rotate file to $output file.1 (or .2 .3) and restart the printing process
Here is the splitting portion:
#! /usr/local/bin/perl
use strict; use warnings;
# Example data - 85_782 lines, 1_072_787 (words), 10_313_190 bytes - filename: syslog
my $split_into = 3; my $line_cnt; my $counter; my $x;
open (ROFILE, "syslog") or die "cannot open syslog $!"; while(<ROFILE>) { ++$line_cnt; } close (ROFILE) or die "cannot close syslog $!";
open (ROFILE, "syslog") or die "cannot re-read syslog $!"; for ($x=0; $x < $split_into; ++$x) {
open (WOFILE, ">syslog.$x") or die "cannot write to syslog.$x $!"; while(<ROFILE>) { print WOFILE $_; ++$counter; last if ($counter >= ($line_cnt/$split_into)); }
$counter = 0; close (WOFILE) or die "cannot close syslog.$x $!"; }
close (ROFILE) or die "cannot close syslog $!"; print "Done ... \n\n"; __END__
Cheers! -Sx-
--
Kind regards,
Remko Lodder
Elvandar.org/DSINet.org
www.mostly-harmless.nl A Dutch community for helping newcomers on the hackerscene
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>