239 lines
4.7 KiB
Groff
239 lines
4.7 KiB
Groff
.\" Copyright 1991 UNIX System Laboratories, Inc.
|
|
.\" Copyright 1989, 1990 AT&T
|
|
.nr X
|
|
.if \nX=0 .ds x} csplit 1 "Directory and File Management Utilities" "\&"
|
|
.TH \*(x}
|
|
.SH NAME
|
|
\f4csplit\f1 \- context split
|
|
.SH SYNOPSIS
|
|
.nf
|
|
\f4csplit\f1 \f1[\f4\-s\f1] \f1[\f4\-k\f1] \f1[\f4\-f\f1 \c
|
|
\f2prefix\f1] [\f4\-n\f1 \f2number\f1] \f2file arg1\f1 [... \f2argn\f1]
|
|
.fi
|
|
.SH DESCRIPTION
|
|
\f4csplit\fP
|
|
reads
|
|
.I file
|
|
and separates it into
|
|
.IR n +1
|
|
sections,
|
|
defined by the arguments
|
|
.IR arg1 "..." argn .
|
|
By default the sections are placed in
|
|
\f4xx00\f1...\f4xx\f2n\f1\f1
|
|
.RI ( n
|
|
may not be greater than 99).
|
|
These sections get the following pieces of
|
|
.IR file :
|
|
.RS 2
|
|
.TP 6
|
|
00:
|
|
From the start of
|
|
.I file
|
|
up to (but not including) the line referenced by
|
|
.IR arg1 .
|
|
.PD 0
|
|
.TP 6
|
|
01:
|
|
From the line referenced by
|
|
.I arg1
|
|
up to the line referenced by
|
|
.IR arg2 .
|
|
.sp .8v
|
|
.RS 6
|
|
\f4\&.\f1
|
|
.sp .8v
|
|
\f4\&.\f1
|
|
.sp .8v
|
|
\f4\&.\f1
|
|
.RE
|
|
.TP 6
|
|
\f2n\f1:
|
|
From the line referenced by
|
|
.I argn
|
|
to the end of
|
|
.IR file .
|
|
.PD
|
|
.RE
|
|
.PP
|
|
If the
|
|
.I file
|
|
argument is a
|
|
\f4\-\f1,
|
|
then standard input is used.
|
|
.PP
|
|
\f4csplit\fP processes supplementary code set characters,
|
|
and recognizes supplementary code set characters in the
|
|
\f2prefix\f1 given to the \f4\-f\f1 option (see below)
|
|
according to the locale specified in the \f4LC_CTYPE\fP
|
|
environment variable (see \f4LANG\fP on \f4environ\fP(5)).
|
|
In regular expressions, pattern searches are performed
|
|
on characters, not bytes, as described on \f4ed\f1(1).
|
|
.PP
|
|
The options to
|
|
\f4csplit\fP
|
|
are:
|
|
.RS 2
|
|
.TP 10
|
|
\f4\-s\f1
|
|
\f4csplit\fP
|
|
normally prints the number of bytes in each file created.
|
|
If the
|
|
\f4\-s\f1
|
|
option is present,
|
|
\f4csplit\fP
|
|
suppresses the printing of all byte counts.
|
|
.TP
|
|
\f4\-k\f1
|
|
\f4csplit\fP
|
|
normally removes created files if an error occurs.
|
|
If the
|
|
\f4\-k\f1
|
|
option is present,
|
|
\f4csplit\fP
|
|
leaves previously created files intact.
|
|
.TP
|
|
\f4\-f\f2 prefix\f1
|
|
If the
|
|
\f4\-f\f1
|
|
option is used, the created files are named
|
|
\f2prefix\f400\c\f1
|
|
\&...\c
|
|
.IR prefixn .
|
|
\f1The default is
|
|
\f4xx00\f1...\f4xx\f2n\f1.\f1
|
|
Supplementary code set characters may be used in \f2prefix\f1.
|
|
.TP
|
|
\f4\-n\f2 number\f1
|
|
Use \f2number\f1 decimal digits to form filenames for the file pieces. The
|
|
default is 2.
|
|
.RE
|
|
.PP
|
|
The arguments
|
|
.RI ( arg1 "..." argn )
|
|
to
|
|
\f4csplit\fP
|
|
can be a combination of the following:
|
|
.RS 2
|
|
.TP 10
|
|
.RI / rexp /
|
|
A file is to be created for the section from the current line
|
|
up to (but not including) the line containing the regular expression
|
|
.IR rexp .
|
|
The line containing
|
|
.IR rexp
|
|
becomes the current line.
|
|
This argument may be followed by an optional
|
|
\f4+\f1 or
|
|
\f4\-\f1
|
|
some number of lines
|
|
(for example, \f4/Page/\-5\fP).
|
|
See \f4ed\f1(1) for a description of how
|
|
to specify a regular expression.
|
|
.TP
|
|
.RI % rexp %
|
|
This argument is the same as
|
|
.RI / rexp /,
|
|
except that no file is created for the section.
|
|
.TP
|
|
.I lnno
|
|
A file is to be created from the current line up to (but not including)
|
|
.IR lnno .
|
|
.IR lnno
|
|
becomes the current line.
|
|
.TP
|
|
.RI { num }
|
|
Repeat argument.
|
|
This argument may follow any of the above arguments.
|
|
If it follows a
|
|
.I rexp
|
|
type argument, that argument is applied
|
|
.I num
|
|
more times.
|
|
If it follows
|
|
.IR lnno ,
|
|
the file will be split every
|
|
.I lnno
|
|
lines
|
|
.RI ( num
|
|
times)
|
|
from that point.
|
|
.RE
|
|
.PP
|
|
Enclose all
|
|
.I rexp
|
|
type arguments that contain blanks or other characters meaningful to
|
|
the shell in the appropriate quotes.
|
|
Regular expressions may not contain embedded new-lines.
|
|
\f4csplit\fP
|
|
does not affect the original file;
|
|
it is the user's responsibility to remove it
|
|
if it is no longer wanted.
|
|
.SH EXAMPLES
|
|
.PP
|
|
.RS
|
|
.ft 4
|
|
csplit \-f cobol file '/procedure division/' /par5./ /par16./
|
|
.ft 1
|
|
.RE
|
|
.PP
|
|
This example creates four files,
|
|
\f4cobol00\f1...\f4cobol03\f1.
|
|
After editing the ``split'' files, they can be recombined as follows:
|
|
.PP
|
|
.RS
|
|
.ft 4
|
|
cat cobol0[0\-3] > file
|
|
.ft 1
|
|
.RE
|
|
.PP
|
|
Note that this example overwrites the original file.
|
|
.PP
|
|
.RS
|
|
.ft 4
|
|
csplit \-k file 100 {99}
|
|
.ft 1
|
|
.RE
|
|
.PP
|
|
This example splits the file at every 100 lines, up to 10,000 lines.
|
|
The
|
|
\f4\-k\f1
|
|
option causes the created files to be retained if there
|
|
are less than 10,000 lines; however, an error message would
|
|
still be printed.
|
|
.PP
|
|
.RS
|
|
.ft 4
|
|
csplit \-k prog.c '%main(%\' '/^}/+1' {20}
|
|
.ft 1
|
|
.RE
|
|
.PP
|
|
If
|
|
\f4prog.c\f1
|
|
follows the normal
|
|
C
|
|
coding convention
|
|
(the last line of a routine consists only of a
|
|
\f4}\f1
|
|
in the first character position),
|
|
this example creates a file for each separate
|
|
C
|
|
routine (up to 21) in
|
|
\f4prog.c\f1.
|
|
.SH FILES
|
|
.TP
|
|
\f4/usr/lib/locale/\f2locale\f4/LC_MESSAGES/uxdfm\f1
|
|
language-specific message file (See \f4LANG\fP on \f4environ\f1(5).)
|
|
.SH SEE ALSO
|
|
ed(1),
|
|
sh(1),
|
|
regexp(5).
|
|
.SH DIAGNOSTICS
|
|
Self-explanatory except for:
|
|
.IP
|
|
\f2arg\fP \- out of range
|
|
.PP
|
|
which means that the given argument did not reference a line
|
|
between the current position and the end of the file.
|
|
.\" @(#)csplit.1 6.2 of 9/2/83
|