csplit

Split a file based on the context (POSIX)

Syntax:

csplit [-ks] [-f prefix] [-n digits] file arg1 [... argn]

Runs on:

QNX Neutrino

Options:

-f prefix
Use prefix instead of xx to name the output files (i.e., name the created files prefix00, prefix01, ..., prefixn instead of xx00, ..., xxn).
-k
Leave previously created files intact. By default, csplit removes created files if an error occurs.
-n digits
The number of digits to append to the prefix. The default is 2.
-s
Suppress the output of file size messages.

Description:

The csplit utility splits a file into n + 1 sections, as prescribed by arg1...argn, and then displays the size of the output files.

Each argument specifies where a section ends as follows:

/rexp/[relno]
Copy lines until the next line matches the regular expression, rexp. A positive or negative relno specifies a relative line number from the match.
%rexp%[relno]
Same as above, except the lines are discarded instead.
nlines
Copy nlines lines from the file.
{num}
Repeat the preceding argument this number of times.

Examples:

Extract a file that's encoded with uuencode:

csplit mail '%^begin%' '/^end/+1' '%.*%'

Split a file into three parts of 1, 10, and 100 lines:

csplit file 1 10 100

Exit status:

0
Success.
>0
An error occurred.