


_O_n_l_i_n_e _M_a_n_u_a_l             User Commands                 csplit(1)



NNNNAAAAMMMMEEEE
     csplit - context split

SSSSYYYYNNNNTTTTAAAAXXXX
     ccccsssspppplllliiiitttt [----ssss] [----kkkk] [----ffff prefix]]]] file arg1 [... argn]

DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
     _c_s_p_l_i_t reads the named _f_i_l_e and separates it into n+1 sec-
     tions, defined by the arguments _a_r_g_1...  _a_r_g_n.  By default
     the sections are placed in xx00 ...  xx_n (_n may not be
     greater than 99).  These sections get the following pieces
     of _f_i_l_e:

           00:   From the start of _f_i_l_e up to (but not including)
                 the line referenced by _a_r_g_1.
           01:   From the line referenced by _a_r_g_1 up to the line
                 referenced by _a_r_g_2.
                 ....
                 ....
                 ....
           n+1:  From the line referenced by _a_r_g_n to the end of
                 _f_i_l_e.

     The options to _c_s_p_l_i_t are:

           ----ssss         _c_s_p_l_i_t normally prints the character counts
                      for each file created.  If the ----ssss option is
                      present, _c_s_p_l_i_t suppresses the printing of
                      all character counts.

           ----kkkk         _c_s_p_l_i_t normally removes created files if an
                      error occurs.  If the ----kkkk option is present,
                      _c_s_p_l_i_t leaves previously created files
                      intact.

           ----ffff _p_r_e_f_i_x  If the ----ffff option is used, the created files
                      are named _p_r_e_f_i_x00000000 ... _p_r_e_f_i_x_n.  The
                      default is xxxxxxxx00000000 ...  xxxxxxxx_n.

     The arguments (_a_r_g_1 ...  _a_r_g_n) to _c_s_p_l_i_t can be a combina-
     tion of the following:

           /_r_e_x_p/  A file is to be created for the section from
                   the current line up to (but not including) the
                   line containing the regular expression _r_e_x_p.
                   The current line becomes the line containing
                   _r_e_x_p.  This argument may be followed by an
                   optional ++++ or ---- some number of lines (e.g.,
                   ////PPPPaaaaggggeeee////----5555).

           %_r_e_x_p%  This argument is the same as /_r_e_x_p/, except
                   that no file is created for the section.

           _l_n_n_o    A file is to be created from the current line
                   up to (but not including) _l_n_n_o.  The current
                   line becomes _l_n_n_o.

           {_n_u_m}   Repeat argument.  This argument may follow any
                   of the above arguments.  If it follows a _r_e_x_p






                   type argument, that argument is applied _n_u_m
                   more times.  If it follows _l_n_n_o, the file will
                   be split every _l_n_n_o lines (_n_u_m times) from
                   that point.

     Enclose all _r_e_x_p type arguments that contain blanks or other
     characters meaningful to the Shell in the appropriate
     quotes.  Regular expressions may not contain embedded new-
     lines.  _C_s_p_l_i_t does not affect the original file; it is the
     users responsibility to remove it.

EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
               csplit -f cobol file  '/procedure division/'  /par5./  /par16./

     This example creates 4 files, ccccoooobbbboooollll00000000 ... ccccoooobbbboooollll00003333.  After
     editing the ``split'' files, they can be recombined as fol-
     lows:

               cat cobol0[0-3] > file

     Note that this example overwrites the original file.

               csplit -k file  100  {99}

     This example would split the file at every 100 lines, up to
     10,000 lines.  The ----kkkk option causes the created files to be
     retained if there are less than 10,000 lines; however, an
     error message would still be printed.

          csplit -k prog.c  '%main(%'  '/^}/+1'  {20}

     Assuming that pppprrrroooogggg....cccc follows the normal CCCC coding convention
     of ending routines with a }}}} at the beginning of the line,
     this example will create a file containing each separate CCCC
     routine (up to 21) in pppprrrroooogggg....cccc.

SSSSEEEEEEEE AAAALLLLSSSSOOOO
     User Commands (1):  ed, sh

DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
     Self explanatory except for:
               arg - out of range
     which means that the given argument did not reference a line
     between the current position and the end of the file.

March 1989                                    TX User's Reference














