Open System Services Shell and Utilities Reference Manual (G06.28+, H06.05+)
User Commands (c) csplit(1)
{number}
Repeats the preceding argument the specified number of times. This number
can follow any of the pattern or line_number arguments. If it follows a pattern
argument, the csplit command reuses that pattern the specified number of
times. If it follows a line_number argument, csplit splits the file from that
point every line_number of lines for number times.
Place within quotation marks all pattern arguments that contain spaces or other charac-
ters special to the shell. Patterns may not contain embedded newline characters.
See the reference page for the grep command for information about creating patterns. In
an expression such as [a-z], the dash means "through" according to the current collating
sequence. The collating sequence is determined by the value of the LC_COLLATE
environment variable.
EXAMPLES
a. To split the text of a book into a separate file for each chapter, enter:
csplit book "/ˆChapter *[0-9]/" {9}
This command creates files named xx00, xx01, xx02,...,xx09, and xx10, which
contain individual chapters of the file book. The file xx00 contains the front
matter that comes before the first chapter. The {9} after the pattern causes the
csplit command to create individual chapters up until file xx09; the remainder of
book is then placed in file xx10.
b. To specify the prefix for the created filenames, enter:
csplit -f chap book "/ˆChapter *[0-9]/" {9}
This command splits book into files named chap00, chap01,...chap9, and
chap10.
RELATED INFORMATION
Commands: ed(1), sh(1), split(1).
Files: locale(4).
527188-007 Hewlett-Packard Company 2−83