1 .\" $NetBSD: csplit.1,v 1.3 2009/01/04 17:26:24 wiz Exp $
3 .\" Copyright (c) 2002 Tim J. Robbins.
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 .\" $FreeBSD: src/usr.bin/csplit/csplit.1,v 1.11 2005/01/25 22:29:51 tjr Exp $
34 .Nd split files based on context
46 into pieces using the patterns
54 reads from standard input.
56 Files are created with a prefix of
58 and two decimal digits.
59 The size of each file is written to standard output
61 If an error occurs whilst files are being created,
68 all files previously written are removed.
70 The options are as follows:
71 .Bl -tag -offset indent -width 10n
73 Create file names beginning with
78 Do not remove previously created files if an error occurs or a
85 Create file names beginning with
87 of decimal digits after the prefix,
90 Do not write the size of each output file to standard output as it is
96 operands may be a combination of the following patterns:
97 .Bl -tag -offset indent -width 10n
98 .It / Ns Ar regexp Ns / Ns Oo Oo Cm + Ns | Ns Cm - Oc Ns Ar offset Oc
99 Create a file containing the input from the current line to (but not including)
100 the next line matching the given basic regular expression.
103 from the line that matched may be specified.
104 .It % Ns Ar regexp Ns % Ns Oo Oo Cm + Ns | Ns Cm - Oc Ns Ar offset Oc
105 Same as above but a file is not created for the output.
107 Create containing the input from the current line to (but not including)
108 the specified line number.
110 Repeat the previous pattern the specified number of times.
111 If it follows a line number pattern, a new file will be created for each
116 The first line of the file is line number 1 for historic reasons.
119 After all the patterns have been processed, the remaining input data
120 (if there is any) will be written to a new file.
122 Requesting to split at a line before the current line number or past the
123 end of the file will result in an error.
128 .Ev LANG , LC_ALL , LC_COLLATE ,
131 environment variables affect the execution of
140 into one file for each section (up to 20):
142 .Dl "$ csplit -k foo.1 '%^\e.Sh%' '/^\e.Sh/' '{20}'"
144 Split standard input after the first 99 lines and every 100 lines thereafter:
146 .Dl "$ csplit -k - 100 '{19}'"
159 command appeared in PWB UNIX.
161 Input lines are limited to
163 (2048) bytes in length.