file too large

Guy Harris guy at auspex.auspex.com
Fri Sep 22 05:19:59 AEST 1989


 > >I have a text file that is very large (26,000+ lines) and would like
 > >to break it down to 5-6 smaller files. Is there an easy way to handle
 > >this? I have tried vi but, it seems to hold 5000 lines in its buffer.
 > >The same goes for ed and ex.
 >
 >There is a program called csplit that should do the trick.

There is a program called "csplit" in some, but not all, versions of
UNIX that might do the trick; it splits based on "context" (which is
presumably what the "c" in "csplit" stands for).  From the SunOS 4.0 man
page:

DESCRIPTION
     csplit reads the file whose name is filename  and  separates
     it  into  n+1  sections,  defined by the arguments argument1
     through argumentn.  If the filename argument is a  `-',  the
     standard  input is used.  By default the sections are placed
     in files named xx00 through xxn.  n may not be greater  than
     99.   These  sections  receive the following portions of the
     file:

     xx00    From the start of filename up to (but not including)
             the  line  indicated by argument1 (see OPTIONS below
             for an explanation of these arguments.)
     xx01:   From the line indicated by argument1 up to the  line
             indicated by argument2.
     xxn:    From the line referenced by argumentn to the end  of
             filename.

However, it is, as noted, not present in all versions of UNIX; it
doesn't come with 4.xBSD, for instance.  "split", which splits based on
line count, is present in all versions of UNIX AT&T has shipped, and is,
as such, more likely to be present in any given version of UNIX (it is
in 4.xBSD). 



More information about the Comp.unix.questions mailing list