Linux Split Command: How to Divide Large Files
This article explains the function and usage of the Linux
split command, a core utility used to break large files
into smaller, manageable pieces. You will learn the basic syntax of the
command, how to divide files based on specific byte sizes or line
counts, how to customize output filenames, and how to recombine the
split chunks back into the original file using standard terminal
tools.
The Function of the Split Command
The primary function of the split command in Linux is to
take an input file and divide it into smaller segment files. This is
particularly useful when transferring large archives across networks
with strict file size limitations, storing data on storage media with
constrained capacity, or processing massive datasets (like log files)
that are too resource-intensive to open in memory all at once.
By default, without any specific arguments other than the filename,
split divides a file into chunks of 1,000 lines each. The
output files are named using a default prefix of x followed
by alphabetical suffixes (e.g., xaa, xab,
xac).
Basic Syntax
The standard syntax for the command is:
split [options] [input_file] [prefix]input_file: The path to the file you want to break apart. If omitted, standard input (stdin) is used.prefix: An optional string appended to the beginning of each generated chunk's filename.
Splitting by File Size
To split a file by a specific data size rather than line count, use
the -b option followed by the desired size and unit (such
as K, M, or G for kilobytes,
megabytes, or gigabytes).
To divide a large video file into 500-megabyte chunks:
split -b 500M video.mp4 part_This creates files named part_aa, part_ab,
part_ac, and so forth, each measuring 500 MB (except the
final chunk, which contains the remainder).
Splitting by Line Count
For text-based data like CSVs, SQL dumps, or logs, use the
-l option to split based on the number of lines per output
file.
To divide a server log into chunks of 5,000 lines each:
split -l 5000 access.log log_chunk_Using Numeric Suffixes
By default, split appends alphabetical characters to
identify pieces. If you prefer numerical numbering (e.g.,
part_00, part_01), include the -d
flag.
split -b 100M -d data.iso data_part_You can also specify the suffix length using
--additional-suffix to add a file extension or
-a to define the number of digits in the index:
split -b 50M -d -a 3 --additional-suffix=.bin backup.tar chunk_This command generates files named chunk_000.bin,
chunk_001.bin, and so on.
Reassembling Split Files
To restore the generated chunks back into the original file, use the
cat (concatenate) command with output redirection:
cat part_* > original_file.mp4The shell expands part_* in alphabetical or numerical
order, ensuring the data is merged sequentially back into its original
state.