1 .\" Copyright (c) 2002 Tim J. Robbins.
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .Nd split files based on context
44 into pieces using the patterns
52 reads from standard input.
54 Files are created with a prefix of
56 and two decimal digits.
57 The size of each file is written to standard output
59 If an error occurs whilst files are being created,
66 all files previously written are removed.
68 The options are as follows:
69 .Bl -tag -width indent
71 Create file names beginning with
76 Do not remove previously created files if an error occurs or a
83 Create file names beginning with
85 of decimal digits after the prefix,
88 Do not write the size of each output file to standard output as it is
94 operands may be a combination of the following patterns:
95 .Bl -tag -width indent
98 .Cm / Ar regexp Cm / Op Oo Cm + | - Oc Ar offset
101 Create a file containing the input from the current line to (but not including)
102 the next line matching the given basic regular expression.
105 from the line that matched may be specified.
108 .Cm % Ar regexp Cm % Op Oo Cm + | - Oc Ar offset
111 Same as above but a file is not created for the output.
113 Create containing the input from the current line to (but not including)
114 the specified line number.
115 .It Cm { Ns Ar num Ns Cm }
116 Repeat the previous pattern the specified number of times.
117 If it follows a line number pattern, a new file will be created for each
122 The first line of the file is line number 1 for historic reasons.
125 After all the patterns have been processed, the remaining input data
126 (if there is any) will be written to a new file.
128 Requesting to split at a line before the current line number or past the
129 end of the file will result in an error.
132 .Ev LANG , LC_ALL , LC_COLLATE
135 environment variables affect the execution of
146 into one file for each section (up to 21 plus one for the rest, if any):
148 .Dl "csplit -k foo.1 '%^\e.Sh%' '/^\e.Sh/' '{20}'"
150 Split standard input after the first 99 lines and every 100 lines thereafter:
152 .Dl "csplit -k - 100 '{19}'"
165 command appeared in PWB UNIX.
167 Input lines are limited to
169 (2048) bytes in length.