Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ed(1)

fsplit(1)

sh(1)

split(1)

regexp(5)




csplit(1) csplit(1)
NAME csplit - context split SYNOPSIS csplit [-f prefix] [-k] [-s] file arg1 [...argn] DESCRIPTION csplit reads file and separates it into n+1 sections, de- fined by the arguments arg1... argn. By default, the sec- tions are placed in files named xx00... xxn (n may not be greater than 99). These sections get the following pieces of file: 00: From the start of file up to (but not including) the line referenced by arg1. 01: From the line referenced by arg1 up to the line referenced by arg2. . . . n+1: From the line referenced by argn to the end of file. If the file argument is a - then standard input is used. The flag options to csplit are: -s csplit normally prints the character counts for each file created. If the -s flag option is present, csplit suppresses the printing of all character counts. -k csplit normally removes created files if an error occurs. If the -k flag option is present, csplit leaves previously created files intact. -f prefix If the -f flag option is used, the created files are named prefix00 ... prefixn. The de- fault is xx00 ... xxn. The arguments (arg1 ... argn) to csplit can be a combina- tion of the following: /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 becomes the line containing rexp. This argument may be followed by an optional + or April, 1990 1



csplit(1) csplit(1)
- some number of lines (e.g., /Page/-5). %rexp% This argument is the same as /rexp/, except that no file is created for the section. lnno A file is to be created from the current line up to (but not including) lnno. The current line becomes lnno. {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 lnno, the file will be split every lnno 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. csplit does not affect the original file; it is the user's responsibility to remove it. EXAMPLES csplit -f cobol file '/procedure division/' /par5./ /par16./ creates four files, ``cobol00 ... cobol03''. After editing the split files, they can be recombined as follows: cat cobol0[0-3] > file Note that this example overwrites the original file. csplit -k file 100 {99} splits the file at every 100 lines, up to 10,000 lines. The -k flag option causes the created files to be retained if there are less than 10,000 lines; however, an error message would still be printed. csplit -k prog.c '%main(%' '/^}/+1' {20} 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. FILES /usr/bin/csplit 2 April, 1990



csplit(1) csplit(1)
SEE ALSO ed(1), fsplit(1), sh(1), split(1), regexp(5). DIAGNOSTICS Self explanatory except for: arg - out of range which means that the given argument did not reference a line between the current position and the end of the file. April, 1990 3

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026