Manual page for CSPLIT(1V)
csplit - split a file with respect to a given context
SYNOPSIS
csplit
[
-f
prefix
] [
-k
] [
-s
]
filename
argument1
[
...argumentn
]
AVAILABILITY
This command is available with the
System V
software installation option. Refer to
[a manual with the abbreviation INSTALL]
for information on how to install optional software.
DESCRIPTION
csplit
reads the file whose name is
filename
and separates it into
n+1 sections,
defined by the arguments
argument1
through
argumentn.
If the
filename
argument is a
`-',
the standard input is used.
By default the sections are placed in files named
xx00
through
xxn.
n
may not be greater than 99.
These sections receive the following portions of the
file:
- xx00
-
From the start of
filename
up to (but not including) the line indicated by
argument1
(see
OPTIONS
below for an explanation of these arguments.)
- xx01:
-
From the line indicated by
argument1
up to the line indicated by
argument2.
- xxn:
-
From the line referenced by
argumentn
to the end of
filename.
csplit
prints the character counts for each file created,
and removes any files
it creates if an error occurs.
OPTIONS
- -f prefix
-
name the created files
prefix00
through
prefixn.
- -k
-
Suppress removal of created files when an error occurs.
- -s
-
Suppress printing of character counts.
The arguments
argument1
through
argumentn
can be a combination of the following selection operators:
- /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
rexp.
The current line then becomes the line containing
rexp.
This argument may be followed by an optional
`+' or
`-'
some number of lines
(for example,
/Page/-5).
- %rexp%
-
This argument is the same as
/rexp/,
except that no file is created for the selected section.
- lineno
-
A file is to be created from the current line up to (but not including)
lineno.
The current line becomes
lineno.
- {num}
-
Repeat argument.
This argument may follow any of the above arguments.
If it follows a
rexp
type argument, that argument is applied
num
more times.
If it follows
lineno,
the file will be split every
lineno
lines
(num
times) from that point.
Enclose all
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.
EXAMPLES
This example splits the file at every 100 lines, up to 10,000 lines.
csplit -k file 100 {99}
Assuming that
prog.c
follows the normal
C
coding convention of ending routines with a
}
at the beginning of the line,
this example will create a file containing each separate
C
routine (up to 21) in
prog.c.
csplit -k prog.c '%main(%' '/^}/+1' {20}
SEE ALSO
ed.1
sh.1
regexp.3
DIAGNOSTICS
Self-explanatory except for:
arg - out of range
which means that the given argument did not refer to a line
between the current position and the
EOF.
Created by unroff & hp-tools.
© somebody (See intro for details). All Rights Reserved.
Last modified 11/5/97