Skip to content
EntityQ5191594· pop 5· linked from 206 articles

csplit is a shell command for splitting a file into two or more smaller files determined by context lines. The command is commonly available on Unix and Unix-like operating systems.

Described at

The csplit utility shall read the file named by the file operand, write all or part of that file into other files as directed by the arg operands, and write the sizes of the files. Leave previously created files intact. By default, csplit shall remove created files if an error occurs. Use number decimal digits to form filenames for the file pieces. The default shall be 2. A file shall be created using the content of the lines from the current line up to, but not including, the line that results from the evaluation of the regular expression with offset , if any, applied. The regular expression rexp shall follow the rules for basic regular expressions described in XBD Basic Regular Expressions . The application shall use the sequence " /" to specify a character within the rexp . The optional offset shall be a positive or negative integer value representing a number of lines. A positive integer value can be preceded by '+'. If the selection of lines from an offset expression of this type would create a file with zero lines, or one with greater than the number of lines left in the input file, the results are unspecified. After the section is created, the current line shall be set to the line that results from the evaluation of the regular expression with any offset applied. If the current line is the first line in the file and a regular expression operation has not yet been performed, the pattern match of rexp shall be applied from the current line to the end of the file. Otherwise, the pattern match of rexp shall be applied from the line following the current line to the end of the file. Repeat operand. This operand can follow any of the operands described previously. If it follows a rexp type operand, that operand shall be applied num more times. If it follows a line no operand, the file shall be split every line no lines, num times, from that point. Provide a default value for the internationalization variables that are unset or null. (See XBD Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.) If set to a non-empty string value, override the values of all the other internationalization variables. Determine the locale for the behavior of ranges, equivalence classes, and multi-character collating elements within regular expressions. Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments and input files) and the behavior of character classes within regular expressions. Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. [XSI) ] ![[Option Start]]( Determine the location of message catalogs for the processing of LC MESSAGES. ![[Option End]]( If the -k option is specified, created files shall be retained. Otherwise, the default action occurs. The output files shall contain portions of the original input file; otherwise, unchanged. 2. This example would split the file after the first 99 lines, and every 100 lines thereafter, up to 9999 lines; this is because lines in the file are numbered from 1 rather than zero, for historical reasons: Consideration was given to adding a -a flag to use the alphabetic filename generation used by the historical split utility, but the functionality added by the -n option was deemed to make alphabetic naming unnecessary. This utility is marked as part of the User Portability Utilities option. The description of regular expression operands is changed to align with the IEEE P1003.2b draft standard. The normative text is reworded to avoid use of the term "must" for application requirements. The csplit utility is moved from the User Portability Utilities option to the Base. User Portability Utilities is now an option for interactive utilities. The SYNOPSIS and OPERANDS sections are revised to use a single arg to split a fil

Excerpt from a page describing this subject · 10,470 chars · not written by Vinony

Wikidata facts

Show 2 more facts
Sources (1)

via Wikidata · CC0

~1 min read

Article

6 sections
Contents
  • Usage
  • Comparison to split
  • See also
  • References
  • Further reading
  • External links

csplit is a shell command for splitting a file into two or more smaller files determined by context lines. The command is commonly available on Unix and Unix-like operating systems.

The command is part of the X/Open Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX and the Single Unix Specification. It first appeared in PWB UNIX. The version in GNU coreutils was written by Stuart Kemp and David MacKenzie. The command is available for Windows via UnxUtils.

Available in 5 languages

via Wikidata sitelinks · CC0

Connections

Categories