Linux split Command: Divide Large Files into Smaller Parts
split divides a large file into multiple piece files based on a specified size or number of lines. It is used to split files according to transmission limits or to create batch processing units.
What is the split command?
By default, it splits in units of 1000 lines and uses prefixes/suffixes like xaa. Binary files can be cut in bytes, and they can be restored if concatenated in the original order. Choose a prefix so that the output files do not conflict with existing files.
Basic syntax
split [options] [input_file [output_prefix]]
Installed implementations and options may vary depending on the distribution. Check the current system's description with man split.
Examples
Split by number of lines
Saves to separate files in units of 500 lines.
split -l 500 data.txt part-
Split by size
Creates pieces of about 100 MiB each.
split -b 100M archive.bin archive-part-
Recombine in order
Check the order of the piece names and then join them together.
cat archive-part-* > archive-restored.bin
Checking the files created after splitting
The following command splits four lines into two lines each. Since part-aa and part-ab will be created in the current directory, try it in an empty working directory.
printf 'a\nb\nc\nd\n' | split -l 2 - part- cat part-aa cat part-ab
An example of displaying the contents of the two files in order:
a b c d
split itself does not print the filenames. If files with the same name already exist, they may be overwritten, so set a unique prefix. To combine them in the original order, list the filenames in the correct order and use cat part-* > restored_file, then check the size or checksum of the restored result.
Main Options and Format
| Options/Format | Description |
|---|---|
-l N |
Put N lines in each file. |
-b size |
Specify the maximum byte size of each piece. |
-d |
Use numeric suffixes. |
-a N |
Specify the suffix length as N characters. |
--additional-suffix=value |
Append an additional string to the end of the split file name. |
Precautions when using
split -b can split even in the middle of text lines. To preserve lines, check the behavior of -l or GNU -C. When merging pieces, it is safe to select only the files with the corresponding prefix and compare with the original using a hash.
Frequently Asked Questions
Are the original files deleted when split with split?
No. The input file remains as is, and new split files are created.
Official Documentation
The exact behavior of options and differences between implementations can be found in the official documentation for split.









