csplit
[options] file argumentsSeparate file into sections and place sections in files named xx00
through xx
n (n < 100), breaking file at each pattern specified in arguments. See also split.
-f
fileName new files file00
through fileN (default is xx00
through xx
n).
-k
Keep newly created files, even when an error occurs (which would normally remove these files). This is useful when you need to specify an arbitrarily large repeat argument, {
n}
, and you don't want the "out of range" error to remove the new files.
-s
Suppress all character counts.
Any one or a combination of the following expressions. Arguments containing blanks or other special characters should be surrounded by single quotes.
/
expr/
Create file from the current line up to the line containing the regular expression expr. This argument takes an optional suffix of the form +
n or -
n, where n is the number of lines below or above expr.
%
expr%
Same as /
expr/
, except no file is created for lines previous to line containing expr.
Create file from current line up to line number num.
{
n}
Repeat argument n times. May follow any of the above arguments. Files will split at instances of expr or in blocks of num lines.
Create up to 20 chapter files from the file novel:
csplit -k -f chap. novel '%CHAPTER%' '{20}'
Create up to 100 address files (xx00 through xx99), each four lines long, from a database named address_list:
csplit -k address_list 4 {99}