csplit(1)             MPE/iX Shell and Utilities             csplit(1)
  ______________________________________________________________________

  NAME
       csplit -- split a text file, according to criteria

  SYNOPSIS
       csplit [-Aaks] [-f prefix] [-n number] file arg arg ...

  DESCRIPTION
       csplit takes a text file as input and breaks up its contents into
       pieces, based on criteria given by the arg value(s) on the com-
       mand line.  For example, you can use csplit to break up a text
       file into chunks of ten lines each, then save each of those
       chunks in a separate file.  See the subsection Splitting Criteria
       for more details.  If you specify - as the file argument, csplit
       uses the standard input.

       The files created by csplit normally have names of the form

          xxnumber

       where number is a two digit decimal number which begins at zero
       and increments by one for each new file that csplit creates.

       csplit also displays the size, in bytes, of each file that it
       creates.

  Options
       csplit accepts the following options:

       -A   uses uppercase letters in place of numbers in the number
            portion of created file names.  This generates names of the
            form xxAA, xxAB, and so on.

       -a   uses lowercase letters in place of numbers in the number
            portion of created file names.  This generates names of the
            form xxaa, xxab, and so on.

       -f prefix
            specifies a prefix to use in place of the default xx when
            naming files.  If prefix causes a file name longer than
            NAME_MAX bytes, an error occurs and csplit exits without
            creating any files.

       -k   leaves all created files intact.  Normally, when an error
            occurs, csplit removes files that it has created.

       -n number
            specifies the number of digits in the number portion of
            created file names.

       -s   suppresses the display of file sizes.

                                                                       1

  csplit(1)             MPE/iX Shell and Utilities             csplit(1)
  ______________________________________________________________________

  Splitting Criteria
       csplit processes the args on the command line sequentially.  The
       first argument breaks off the first chunk of the file, the second
       argument breaks off the next chunk (beginning at the first line
       remaining in the file), and so on.  Thus each chunk of the file
       begins with the first line remaining in the file and goes to the
       line given by the next arg.

       arg values may take any of the following forms:

       /regexp/  takes the chunk as all the lines from the current line
                 up to but not including the next line that contains a
                 string matching the regular expression regexp. regexp
                 is a basic regular expression (see regexp(3)).  After
                 csplit has obtained the chunk and written it to an out-
                 put file, it sets the current line to the line that
                 matched regexp.

       /regexp/offset
                 is the same as the previous criterion, except that the
                 chunk goes up to but not including the line that is a
                 given offset from the first line containing a string
                 that matches regexp. The offset may be a positive or
                 negative integer.  After csplit has obtained the chunk
                 and written it to an output file, it sets the current
                 line to the line that matched regexp.

                 Note: This current line is the first one that was not
                 part of the chunk just written out.

       %regexp%  is the same as /regexp/, except that csplit does not
                 write the chunk to an output file.  It simply skips
                 over the chunk.

       %regexp%offset
                 is the same as /regexp/offset, except csplit does not
                 write the chunk to an output file.

       linenumber
                 obtains a chunk beginning at the current line and going
                 up to but not including the linenumberth line.  After
                 split writes the chunk to an output file, it sets the
                 current line to linenumber.

       {number}  repeats the previous criterion number times.  If it
                 follows a regular expression criterion, it repeats the
                 regular expression process number more times.  If it
                 follows a linenumber criterion, csplit splits the file
                 every linenumber lines, number times, beginning at the
                 current line.  For example,

                    csplit file 10 {10}

                                                                       2

  csplit(1)             MPE/iX Shell and Utilities             csplit(1)
  ______________________________________________________________________

                 obtains a chunk from line 1 to line 9, then every 10
                 lines after that, up to line 109.

       Errors occur if any criterion tries to grab lines beyond the end
       of the file, if a regular expression does not match any line
       between the current line and the end of the file, or if an offset
       refers to a position before the current line or past the end of
       the file.

  DIAGNOSTICS
       Possible exit status values are:

       0  Successful completion.

       1  Failure due to any of the following:
            -- because csplit was unable to open the input or output files
            -- a write error on the output file.

       2  Failure due to any of the following:
            -- unknown command line option
            -- the prefix name was missing after -f
            -- the number of digits was missing after -n
            -- the input file was not specified
            -- no arg values were specified
            -- the command ran out of memory
            -- an arg was invalid
            -- the command found end-of-file prematurely
            -- a regular expression in an arg was badly formed
            -- a line offset/number in an arg was badly formed
            -- a {number} repetition count was misplaced or badly formed
            -- too many file names were generated when using -n
            -- generated file names would be too long.

  Messages

       Message:  Badly formed line number "linenumber"
       Cause:    You specified a linenumber that was not a valid inte-
                 ger.
       Action:   Specify a valid integer for linenumber.

       Message:  Badly formed line offset in "offset"
       Cause:    You specified an offset that was not a valid integer.
       Action:   Specify a valid integer for offset.

       Message:  Badly formed regular expression regexp
       Cause:    You specified the regular expression regexp, but it did
                 not contain a closing / or %.
       Action:   Provide the missing / or %.

       Message:  Badly formed {repeat} count "number"
       Cause:    You specified a {number} that was not a valid integer.
       Action:   Specify a valid integer for number.

                                                                       3

  csplit(1)             MPE/iX Shell and Utilities             csplit(1)
  ______________________________________________________________________

       Message:  cannot create temporary file: system error
       Cause:    See syserror(3).
       Action:   See syserror(3).

       Message:  csplit argument must be one of ...
       Cause:    You specified an argument to csplit that did not look
                 like a regular expression, line number, or repeat
                 count.
       Action:   Check the syntax of your command line, correct any mis-
                 takes, and  re-enter it.

       Message:  error in regular expression regexp: regular expression
                 error
       Cause:    See regerror(3).
       Action:   See regerror(3).

       Message:  Generated filenames would be too long
       Cause:    You specified an argument for the -n option that when
                 combined with the length of the specified prefix
                 resulted in a generated file name that was longer than
                 the file system permits.
       Action:   Specify a shorter prefix or a lower value for the argu-
                 ment to the -n option.

       Message:  input file "filename": system error
       Cause:    See syserror(3).
       Action:   See syserror(3).

       Message:  insufficient memory: system error
       Cause:    See syserror(3).
       Action:   See syserror(3).

       Message:  Misplaced {number} repetition count
       Cause:    You specified a {number} repetition count before speci-
                 fying the splitting criteria, or you specified the
                 count without specifying any criteria at all.
       Action:   Make sure that any {number} arguments follow the appro-
                 priate criteria specification on the command line.

       Message:  missing input file
       Cause:    You did not specify an input file.
       Action:   Specify an input file.

       Message:  Missing number of digits
       Cause:    You specified the -n option but did not provide an
                 argument to indicate the number of digits to use when
                 generating file names.
       Action:   Provide the missing argument.

       Message:  Missing prefix file name
       Cause:    You specified the -f option but did not provide a pre-
                 fix as an argument.

                                                                       4

  csplit(1)             MPE/iX Shell and Utilities             csplit(1)
  ______________________________________________________________________

       Action:   Provide the missing prefix.

       Message:  need at least one section argument
       Cause:    You did not specify any splitting criteria.
       Action:   Specify at least one argument which defines splitting
                 criteria.

       Message:  num1 digits specified (limit allowed)
       Cause:    You specified an argument to the -n option that was
                 greater than the number of digits allowed by csplit
                 (that is, limit).

       Message:  output file "filename": system error
       Cause:    See syserror(3).
       Action:   See syserror(3).

       Message:  too many file names generated, use "-n" option
       Cause:    You specified a set of criteria that created more files
                 than csplit was able to generate names for, given the
                 number of digits in the numeric portion of file names.
       Action:   Specify criteria that creates fewer files, or use the
                 -n option to increase the number of digits in the
                 numeric portion of file names.

       Message:  Unknown option "-option"
       Cause:    You specified an option that is not valid for split.
       Action:   Check the DESCRIPTION section for a list of valid
                 csplit options.

       Message:  Warning: premature EOF at "arg"
       Cause:    csplit reached the end-of-file before completing the
                 search for arg.
       Action:   Specify criteria that will not cause csplit to try
                 searching past the end of the file.

       Message:  write error on file "filename": system error
       Cause:    See syserror(3).
       Action:   See syserror(3).

  PORTABILITY
       POSIX.2.  x/OPEN Portability Guide 4.0.  All UNIX systems.

       The -A and -a options are extensions to the POSIX standard.

  MPE/iX NOTES
       For information on how the current MPE/iX implementation may
       affect the operation of this utility, see Appendix A, MPE/iX
       Implementation Considerations.

  SEE ALSO
       awk(1), sed(1), regexp(3)

                                                                       5