split(1) — Commands
NAME
split − Splits a file into pieces
SYNOPSIS
Current syntax
split [-l line_count] [-a suffix_length] [file | -] [prefix]
split -b n[k | m] [-a suffix_length] [file | -] [prefix]
Obsolescent syntax
split [-number] [-a suffix_length] [file | -] [prefix] The split command reads file and writes it in number-line pieces (default 1000 lines) to a set of output files.
FLAGS
-a suffix_length
Uses suffix_length letters to form the suffix portion of the filenames of the split file. If -a is not specified, the default suffix length is two letters. If the sum of the prefix and the suffix arguments would create a filename exceeding NAME_MAX bytes, an error occurs. In this case, split exits with a diagnostic message and no files are created.
-b nSplit a file into pieces n bytes in size.
-b nkSplit a file into pieces n kilobytes (1024 bytes) in size.
-b nmSplit a file into pieces n megabytes (1048576 bytes) in size.
-l line_count
Specifies the number of lines in each output file. The line_count argument is an unsigned decimal integer. The default value is 1000. If the input does not end with a newline character, the partial line is included in the last output file.
-numberSpecifies the number of lines in each output file. The default is 1000 lines per output file. (Obsolescent)
DESCRIPTION
The size of the output files can be modified by using the -b or -l flags. Each output file is created with a unique suffix consisting of exactly suffix lowercase letters from the POSIX locale. The letters of the suffix are used as if they were a base-26 digit system, with the first suffix to be created consisting of all a characters, the second with b replacing the last a etc., until a name of all zs is created. By default, the names of the output files are x, followed by a two-character suffix from the character set as described above, starting with aa, ab, ac, etc., and continuing until the suffix zz, for a maximum of 676 files.
The value of prefix cannot be longer than the value of NAME_MAX from limits.h minus two.
If the number of files required is greater than the maximum allowed by the effective suffix length (such that the last allowable file would be larger than the requested size), split fails after creating the last possible file with a valid suffix. The split command will not delete the files it created with valid suffixes. If the file limit is not exceeded, the last file created contains the remainder of the input file and thus might be smaller than the requested size.
If you do not specify an input file, or if you specify -
EXAMPLES
1.To split a file into 1000-line segments, enter:
split book
This splits book into 1000-line segments named xaa, xab, xac, and so forth.
2.To split a file into 50-line segments and specify the filename prefix, enter:
split -l50 book sect
This splits book into 50-line segments named sectaa, sectab, sectac, and so forth.