Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ csplit(1) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                                csplit(1)



        _________________________________________________________________
        csplit                                                    Command
        context split
        _________________________________________________________________


        SYNTAX

        csplit [-s] [-k] [-f prefix] file arg1 [... argn]


        DESCRIPTION

        Csplit reads file and separates it into n+1 sections, defined by
        the arguments arg1...  argn.  By default the sections are placed
        in files labeled xx00 ...  xxn (n may not be greater than 99).
        These sections get the following pieces of file:

              00:   From the start of file up to (but not including) the
                    line referenced by arg1.
              01:   From the line referenced by arg1 up to the line
                    referenced by arg2.
                    .
                    .
                    .
              n+1:  From the line referenced by argn to the end of file.

        If the file argument is a - then standard input is used.

        Options are:

              -s         Suppresses the printing of all character counts.
                         Csplit normally prints the character counts for
                         each file created.

              -k         Leaves previously created files intact.  Csplit
                         normally removes created files if an error
                         occurs.

              -f prefix  The created files are named prefix00 ...
                         prefixn.  The default is xx00 ...  xxn.

        The arguments (arg1 ...  argn) to csplit can be a combination of
        the following:

              /rexp/  Create a file for the section from the current line
                      up to (but not including) the line containing the
                      regular expression rexp.  The current line becomes
                      the line containing rexp.  This argument may be
                      followed by an optional + or - some number of lines
                      (e.g., /Page/-5).



        DG/UX 4.00                                                 Page 1
               Licensed material--property of copyright holder(s)





                                                                csplit(1)



              %rexp%  The same as /rexp/, but no file is created for the
                      section.

              linenum Create a file from the current line up to (but not
                      including) linenum.  The current line becomes
                      linenum.

              {num}   Repeat argument.  This argument may follow any of
                      the above arguments.  If it follows a rexp type
                      argument, that argument is applied num more times.
                      If it follows linenum, the file will be split every
                      linenum lines (num times) from that point.

        Enclose all rexp type arguments that contain blanks or other
        characters meaningful to the shell in the appropriate quotes.
        Regular expressions may not contain embedded new-lines.  Csplit
        does not affect the original file.


        EXAMPLES

        csplit -f cobol file  '/procedure division/' /par5./  /par16./

        This example creates four files, cobol00 ... cobol03.  After
        editing the ``split'' files, they can be recombined as follows:

                       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 option retains the created files 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 prog.c follows the normal C coding convention of
        ending routines with a } at the beginning of the line, this
        example will create a file containing each separate C routine (up
        to 21) in prog.c.


        SEE ALSO

        ed(1), sh(1).
        regexp(5) in the Programmer's Reference for the DG/UX System





        DG/UX 4.00                                                 Page 2
               Licensed material--property of copyright holder(s)





                                                                csplit(1)



        DIAGNOSTICS

        Self explanatory except for:

                  arg - out of range

        This means that the given argument did not reference a line
        between the current position and the end of the file.














































        DG/UX 4.00                                                 Page 3
               Licensed material--property of copyright holder(s)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026