File: csplit.1

package info (click to toggle)
textutils 1.22-2.4
  • links: PTS
  • area: main
  • in suites: hamm, slink
  • size: 6,480 kB
  • ctags: 2,942
  • sloc: ansic: 31,755; sh: 8,186; perl: 811; makefile: 640; sed: 93
file content (129 lines) | stat: -rw-r--r-- 4,883 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
.TH CSPLIT 1 "GNU Text Utilities" "FSF" \" -*- nroff -*-
.SH NAME
csplit \- split a file into sections determined by context lines
.SH SYNOPSIS
.B csplit
[\-sqkz] [\-f prefix] [\-b suffix] [\-n digits] [\-\-prefix=prefix]
[\-\-suffix\-format=suffix] [\-\-digits=digits] [\-\-quiet] [\-\-silent]
[\-\-keep-files] [\-\-elide\-empty\-files] [\-\-help] [\-\-version]
file pattern...
.SH DESCRIPTION
This documentation is no longer being maintained and may be inaccurate
or incomplete.  The Texinfo documentation is now the authoritative source.
.PP
This manual page
documents the GNU version of
.BR csplit .
.B csplit
creates zero or more output files containing sections of the given
input
.IR file ,
or the standard input if the name `\-' is given.  By default,
.B csplit
prints the number of bytes written to each output file after it has
been created.
.PP
The contents of the output files are determined by the
.I pattern
arguments.  An error occurs if a pattern argument refers to a
nonexistent line of the input file, such as if no remaining line
matches a given regular expression.  After all the given patterns have
been matched, any remaining output is copied into one last output file.
The types of pattern arguments are:
.RS
.TP
.I line
.br
Create an output file containing the current line up to (but not
including) line \fIline\fP (a positive integer) of the input file.  If
followed by a repeat count, also create an output file containing the
next \fIline\fP lines of the input file once for each repeat.
.TP
/\fIregexp\fP/[\fIoffset\fP]
.br
Create an output file containing the current line up to (but not
including) the next line of the input file that contains a match for
\fIregexp\fP.  The optional \fIoffset\fP is a `+' or `\-' followed by
a positive integer.  If it is given, the input up to the matching line
plus or minus \fIoffset\fP is put into the output file, and the line
after that begins the next section of input.
.TP
%\fIregexp\fP%[\fIoffset\fP]
.br
Like the previous type, except that it does not create an output file,
so that section of the input file is effectively ignored.
.TP
{\fIrepeat-count\fP}
.br
Repeat the previous pattern \fIrepeat-count\fP (a positive integer)
additional times. An asterisk may be given in place of the (integer)
repeat count, in which case the preceeding pattern is repeated as
many times as necessary until the input is exausted.
.RE
.PP
The output file names consist of a prefix followed by a suffix.  By
default, the suffix is merely an ascending linear sequence of two-digit
decimal numbers starting with 00 and ranging up to 99, however this
default may be overridden by either the
.I \-\-digits
option or by the
.I \-\-suffix\-format
option.  (See below.)  In any case,
concatenating the output files in sorted order by file name
produces the original input file, in order.  The default output file
name prefix is `xx'.
.PP
By default, if
.B csplit
encounters an error or receives a hangup, interrupt, quit, or
terminate signal, it removes any output files that it has created so
far before it exits.
.SS OPTIONS
.TP
.I "\-f, \-\-prefix=prefix"
Use
.I prefix
as the output file name prefix string.
.TP
.I "\-b, \-\-suffix\-format=suffix"
Use
.I suffix
as the output file name suffix string.  When this option is specified,
the suffix string must include exactly one printf(3) style conversion
specification (such as %d, possibly including format
specification flags, a field width, a precision specifications, or all of
these kinds of modifiers).  The conversion specification must be
suitable for converting a binary integer argument to readable form.
Thus, only `d', 'i', `u', `o', `x', and `X' format specifiers are allowed.
The entire suffix string is given
(with the current output file number) to sprintf(3) to form the file
name suffixes for each of the individual output files in turn.
Note that when this option is used, the
.I \-\-digits
option is ignored.
.TP
.I "\-n, \-\-digits=digits"
Use output file names containing numbers that are
.I digits
digits long instead of the default 2.
.TP
.I "\-k, \-\-keep-files"
Do not remove output files when errors are encountered.
.TP
.I "\-z, \-\-elide\-empty\-files"
Suppress the generation of zero-length output files.  (In cases where
the section delimiters of the input file are supposed to mark the first
lines of each of the sections, the first output file will generally be a
zero-length file unless you use this option.)  Note that the output file
sequence numbers will always run consecutively, starting from 0,
even in cases where zero-length output sections are suppressed due to the
use of this option.
.TP
.I "\-s, \-q, \-\-silent, \-\-quiet"
Do not print counts of output file sizes.
.TP
.I "\-\-help"
Print a usage message and exit with a status code indicating success.
.TP
.I "\-\-version"
Print version information on standard output then exit.