CSPLIT(1) DOMAIN/IX Reference Manual (SYS5) CSPLIT(1)
NAME
csplit - context split
USAGE
csplit [-s] [-k] [-f prefix ] file arg1 [ ... argn ]
DESCRIPTION
Csplit reads a specified file and separates it into n+1 sec-
tions, defined by the arguments arg1... argn. By default,
it places the sections in xx00 ... xxn (n may not be
greater than 99). These sections comprise 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
-s Suppress the character counts for each file
created.
-k Leave previously-created files intact (even if an
error occurs when using csplit).
-f prefix Name the created files prefix 00 ... prefixn.
The default is xx00 ... xxn.
ARGUMENTS
/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. The argument may be followed by an
optional + or - some number of lines (e.g.,
/Page/-5).
%rexp% Same as /rexp/, except that no file is created
for the section.
lnno Create a file from the current line, up to
(but not including) lnno. The current line
becomes lnno.
{num} Repeat argument. May follow any of the above
Printed 6/10/85 CSPLIT-1
CSPLIT(1) DOMAIN/IX Reference Manual (SYS5) CSPLIT(1)
arguments. If it follows a rexp-type argu-
ment, that argument is applied num more times.
If it follows lnno, the file will be split
every lnno lines (num times) from that point.
EXAMPLES
To create four files, cobol00 ... cobol03, type the follow-
ing:
csplit -f cobol file '/procedure division/' /par5./ /par16./
CSPLIT-2 Printed 6/10/85
CSPLIT(1) DOMAIN/IX Reference Manual (SYS5) CSPLIT(1)
To recombine the ``split'' files after they have been
edited, use this:
cat cobol0[0-3] > file
To overwrite the original file, type the following command:
csplit -k file 100 {99}
To split the file at every 100 lines, up to 10,000 lines --
and to retain the created files if there are less than
10,000 lines, use this command:
csplit -k prog.c '%main(%' '/^}/+1' {20}
Assuming that prog.c follows the normal C coding convention
of ending routines with a right brace (}) at the beginning
of the line, this example will create a file containing each
separate C routine (up to 21) in prog.c.
CAUTIONS
Place all rexp-type arguments containing blanks or other
characters meaningful to sh (1) in appropriate quotes.
Regular expressions may not contain embedded newlines.
Csplit does not affect the original file; therefore, the
file is not automatically removed after using csplit.
DIAGNOSTICS
Self-explanatory except for ``arg - out of range'', which
means that the given argument does not reference a line
between the current position and the end of the file.
RELATED INFORMATION
ed (1), sh (1), regexp (5).
Printed 6/10/85 CSPLIT-3