Annotation of src/usr.bin/csplit/csplit.1, Revision 1.2
1.2 ! jmc 1: .\" $OpenBSD: csplit.1,v 1.1 2006/07/17 16:38:02 millert Exp $
1.1 millert 2: .\"
3: .\" Copyright (c) 2002 Tim J. Robbins.
4: .\" All rights reserved.
5: .\"
6: .\" Redistribution and use in source and binary forms, with or without
7: .\" modification, are permitted provided that the following conditions
8: .\" are met:
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.
14: .\"
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
25: .\" SUCH DAMAGE.
26: .\"
27: .\" $FreeBSD: src/usr.bin/csplit/csplit.1,v 1.11 2005/01/25 22:29:51 tjr Exp $
28: .\"
29: .Dd January 26, 2005
30: .Dt CSPLIT 1
31: .Os
32: .Sh NAME
33: .Nm csplit
34: .Nd split files based on context
35: .Sh SYNOPSIS
36: .Nm
37: .Op Fl ks
38: .Op Fl f Ar prefix
39: .Op Fl n Ar number
40: .Ar file args ...
41: .Sh DESCRIPTION
42: The
43: .Nm
44: utility splits
45: .Ar file
46: into pieces using the patterns
47: .Ar args .
48: If
49: .Ar file
50: is
51: a dash
52: .Pq Sq - ,
53: .Nm
54: reads from standard input.
55: .Pp
56: The options are as follows:
57: .Bl -tag -width indent
58: .It Fl f Ar prefix
59: Give created files names beginning with
60: .Ar prefix .
61: The default is
62: .Dq xx .
63: .It Fl k
64: Do not remove output files if an error occurs or a
65: .Dv HUP ,
66: .Dv INT ,
67: or
68: .Dv TERM
69: signal is received.
70: .It Fl n Ar number
71: Use
72: .Ar number
73: of decimal digits after the
74: .Ar prefix
75: to form the file name.
76: The default is 2.
77: .It Fl s
78: Do not write the size of each output file to standard output as it is
79: created.
80: .El
81: .Pp
82: The
83: .Ar args
84: operands may be a combination of the following patterns:
85: .Bl -tag -width indent
86: .It Xo
87: .Sm off
88: .No / Ar regexp No /
89: .Op Oo Cm + | - Oc Ar offset
90: .Sm on
91: .Xc
92: Create a file containing the input from the current line to (but not including)
93: the next line matching the given basic regular expression.
94: An optional
95: .Ar offset
96: from the line that matched may be specified.
97: .It Xo
98: .Sm off
99: .No % Ar regexp No %
100: .Op Oo Cm + | - Oc Ar offset
101: .Sm on
102: .Xc
103: Same as above but a file is not created for the output.
104: .It Ar line_no
105: Create containing the input from the current line to (but not including)
106: the specified line number.
107: .It { Ns Ar num Ns }
108: Repeat the previous pattern the specified number of times.
109: If it follows a line number pattern, a new file will be created for each
110: .Ar line_no
111: lines,
112: .Ar num
113: times.
114: The first line of the file is line number 1 for historic reasons.
115: .El
116: .Pp
117: After all the patterns have been processed, the remaining input data
118: (if there is any) will be written to a new file.
119: .Pp
120: Requesting to split at a line before the current line number or past the
121: end of the file will result in an error.
122: .Pp
123: .Ex -std
124: .Sh ENVIRONMENT
125: The
126: .Ev LANG , LC_ALL , LC_COLLATE ,
127: and
128: .Ev LC_CTYPE
129: environment variables affect the execution of
130: .Nm
131: as described in
132: .Xr environ 7 .
133: .Sh EXAMPLES
134: Split the
135: .Xr mdoc 7
136: file
137: .Pa foo.1
138: into one file for each section (up to 20):
139: .Pp
1.2 ! jmc 140: .Dl "$ csplit -k foo.1 '%^\e.Sh%' '/^\e.Sh/' '{20}'"
1.1 millert 141: .Pp
142: Split standard input after the first 99 lines and every 100 lines thereafter:
143: .Pp
1.2 ! jmc 144: .Dl "$ csplit -k - 100 '{19}'"
1.1 millert 145: .Sh SEE ALSO
146: .Xr sed 1 ,
147: .Xr split 1 ,
148: .Xr re_format 7
149: .Sh STANDARDS
150: The
151: .Nm
152: utility conforms to
153: .St -p1003.1-2004 .
154: .Sh HISTORY
155: A
156: .Nm
157: command appeared in PWB UNIX.
158: .Sh BUGS
159: Input lines are limited to
160: .Dv LINE_MAX
161: (2048) bytes in length.