MPE/iX Shell and Utilities Reference Manual, Vol 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 output 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 includ-
ing 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 expres-
sion 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}
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 expres-
sion 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.
Commands and Utilities 1-139