split divides a file into smaller segments, storing the segments in individual output files and leaving the original file unaltered.
The output files are automatically numbered; split uses a suffix comprising two lowercase letters (aa, ab ... zz) from the current internationalized environment for this purpose. The last file contains the remainder of the input file and may contain fewer lines than the number specified.
If the number of output files required exceeds the maximum length allowed by the suffix, split does not write the last file (as this would contain more lines than specified) and terminates with the exit status >0. The files that have already been created are not deleted.
Syntax
Format 1: |
split -b byte[ -a zahl][ datei[ name]] |
Format 2: |
split[ -l zeilen][ -a zahl][ datei[ name]] |
Format 3: |
split[ zeilen][ -a zahl][ datei[ name]] |
No option specified The output files are called |
The suffix for the output file consists of number letters. For example, -a -a not specified:
split splits the input file into sections of size bytes. bytes can be specified as follows:
Name of the input file you want to split. file not specified:
Name of the output files: The first output file is given the name name aa, the second receives the name name ab, and so on lexicographically, up to name zz. If you specify a value for name, the file argument is mandatory. |
|
Locale
The following environment variables affect the execution of split: LANG Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined. LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables. LC_CTYPE Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files), the classification of characters as upper- to lower-case, and the mapping of characters from one case to the other. LC_MESSAGES Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES. |
Example 1
The contents of the file example are to be split into several 20-line files:
|
Example 2
Every two lines from the standard input are to be written into files named out... Since the names of output files are explicitly specified (out) in this case, the minus sign (-) for standard input must not be omitted!
CRTL+D
|
See also
csplit |