File Splitting

sinck@ugive.com sinck@ugive.com
Tue, 5 Dec 2000 08:00:58 -0700


\_ Can you help me out?
Which way did you come in?  :-)

\_ How are you splitting your files, I am in need of away to take a large plain
\_ text database report and break it up into small pieces.

In this case, split isn't your friend, since it doesn't care about
line breaks, which, presumably your plain text database does.

Try successive runs of tail and head, or the following perl script

#!/usr/bin/perl

# invoke: thisfile.pl file_to_split

# YMMV

$lines = 100;      # how many lines/file
$outfile = "xaa";  # base

open (F, "> $outfile");  # initial
while (<>)
{
   print F;
   if (! ($. % $lines))
   {
      close (F);
      $outfile++;  # perl magic
      open (F, "> $outfile");
   }
}	
close(F);


# David