split β split a file into pieces
| Use Case | Command | Description |
|---|---|---|
| Split by default (1000 lines) | split [INPUT] | Split INPUT into files of 1000 lines each, prefix 'x' |
| Split by line count | split -l N INPUT | Split into files with N lines each |
| Split by byte size | split -b SIZE INPUT | Split into files of SIZE bytes (e.g., 10M) |
| Split into N chunks | split -n N INPUT | Create N equal-sized files based on input size |
| Round-robin distribution | split -n r/N INPUT | Distribute lines in round-robin fashion across N files |
| Numeric suffixes | split -d INPUT | Use numeric suffixes (00, 01, β¦) instead of letters |
| Custom prefix | split INPUT PREFIX | Use PREFIX for output file names instead of 'x' |
split [OPTION] [INPUT [PREFIX]]
βsplitβ creates output files containing consecutive or interleaved sections of INPUT (standard input if none is given or INPUT is β-β).
By default, βsplitβ puts 1000 lines of INPUT (or whatever is left over for the last section), into each output file.
The output filesβ names consist of PREFIX (βxβ by default) followed by a group of characters (βaaβ, βabβ, β¦ by default), such that concatenating the output files in traditional sorted order by file name produces the original input file (except β-nr/Nβ). By default split will initially create files with two generated suffix characters, and will increase this width by two when the next most significant position reaches the last character. (βyzβ, βzaaaβ, βzaabβ, β¦). In this way an arbitrary number of output files are supported, which sort as described above, even in the presence of an β--additional-suffixβ option. If the β-aβ option is specified and the output file names are exhausted, βsplitβ reports an error without deleting the output files that it did create.
The program accepts the following options. Also see Common options.
-l LINES, --lines=LINES
π Put LINES lines of INPUT into each output file. If --separator is specified, then LINES determines the number of records. For compatibility split also supports an obsolete option syntax -LINES. New scripts should use -l LINES instead.
-b SIZE, --bytes=SIZE
πΎ Put SIZE bytes of INPUT into each output file. SIZE may be, or may be an integer optionally followed by, one of the following multiplicative suffixes: b = 512 ("blocks"), KB = 1000 (KiloBytes), K = 1024 (KibiBytes), MB = 1000*1000 (MegaBytes), M = 1024*1024 (MebiBytes), GB = 1000*1000*1000 (GigaBytes), G = 1024*1024*1024 (GibiBytes), and so on for T, P, E, Z, and Y. Binary prefixes can be used, too: KiB=K, MiB=M, and so on.
-C SIZE, --line-bytes=SIZE
ππΎ Put into each output file as many complete lines of INPUT as possible without exceeding SIZE bytes. Individual lines or records longer than SIZE bytes are broken into multiple files. SIZE has the same format as for the --bytes option. If --separator is specified, then LINES determines the number of records.
--filter=COMMAND
π§ With this option, rather than simply writing to each output file, write through a pipe to the specified shell COMMAND for each output file. COMMAND should use the $FILE environment variable, which is set to a different output file name for each invocation of the command. For example, imagine that you have a 1TiB compressed file that, if uncompressed, would be too large to reside on disk, yet you must split it into individually-compressed pieces of a more manageable size. To do that, you might run this command:
xz -dc BIG.xz | split -b200G --filter='xz > $FILE.xz' - big-
Assuming a 10:1 compression ratio, that would create about fifty 20GiB files with names βbig-aa.xzβ, βbig-ab.xzβ, βbig-ac.xzβ, etc.
-n CHUNKS, --number=CHUNKS
π¦ Split INPUT to CHUNKS output files where CHUNKS may be:
N β generate N files based on current size of INPUTK/N β only output Kth of N to stdoutl/N β generate N files without splitting lines or recordsl/K/N β likewise but only output Kth of N to stdoutr/N β like l but use round robin distributionr/K/N β likewise but only output Kth of N to stdoutr mode). All N files are created even if there are fewer than N lines, or the INPUT is truncated. For l mode, chunks are approximately INPUT size / N. The INPUT is partitioned into N equal sized portions, with the last assigned any excess. If a line _starts_ within a partition it is written completely to the corresponding file. Since lines or records are not split even if they overlap a partition, the files written can be larger or smaller than the partition size, and even empty if a line/record is so long as to completely overlap the partition. For r mode, the size of INPUT is irrelevant, and so can be a pipe for example.
-a LENGTH, --suffix-length=LENGTH
π’ Use suffixes of length LENGTH. If a LENGTH of 0 is specified, this is the same as if (any previous) -a was not specified, and thus enables the default behavior, which starts the suffix length at 2, and unless -n or --numeric-suffixes=FROM is specified, will auto increase the length by 2 as required.
-d, --numeric-suffixes[=FROM]
π’ Use digits in suffixes rather than lower-case letters. The numerical suffix counts from FROM if specified, 0 otherwise. FROM is supported with the long form option, and is used to either set the initial suffix for a single run, or to set the suffix offset for independently split inputs, and consequently the auto suffix length expansion described above is disabled. Therefore you may also want to use option -a to allow suffixes beyond 99. Note if option --number is specified and the number of files is less than FROM, a single run is assumed and the minimum suffix length required is automatically determined.
-x, --hex-suffixes[=FROM]
π’ Like --numeric-suffixes, but use hexadecimal numbers (in lower case).
--additional-suffix=SUFFIX
β Append an additional SUFFIX to output file names. SUFFIX must not contain slash.
-e, --elide-empty-files
π« Suppress the generation of zero-length output files. This can happen with the --number option if a file is (truncated to be) shorter than the number requested, or if a line is so long as to completely span a chunk. The output file sequence numbers, always run consecutively even when this option is specified.
-t SEPARATOR, --separator=SEPARATOR
π Use character SEPARATOR as the record separator instead of the default newline character (ASCII LF). To specify ASCII NUL as the separator, use the two-character string '\0', e.g., split -t '\0'.
-u, --unbuffered
β‘ Immediately copy input to output in --number r/... mode, which is a much slower mode of operation.
--verbose
π’ Write a diagnostic just before each output file is opened.
An exit status of zero indicates success, and a nonzero value indicates failure.
Here are a few examples to illustrate how the --number (-n) option works:
Notice how, by default, one line may be split onto two or more:
$ seq -w 6 10 > k; split -n3 k; head xa?
==> xaa <==
06
07
==> xab <==
08
0
==> xac <==
9
10
Use the "l/" modifier to suppress that:
$ seq -w 6 10 > k; split -nl/3 k; head xa?
==> xaa <==
06
07
==> xab <==
08
09
==> xac <==
10
Use the "r/" modifier to distribute lines in a round-robin fashion:
$ seq -w 6 10 > k; split -nr/3 k; head xa?
==> xaa <==
06
09
==> xab <==
07
10
==> xac <==
08
You can also extract just the Kth chunk. This extracts and prints just the 7th "chunk" of 33:
$ seq 100 > k; split -nl/7/33 k
20
21
22
Common options (coreutils info).
Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-31 14:20 @216.73.217.152
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format