$linuxjunkies
>

split(1)

Split a file into smaller pieces by lines, bytes, or patterns.

UbuntuDebianFedoraArch

Synopsis

split [OPTION]... [FILE] [OUTPUT_PREFIX]

Description

The split command divides a file into smaller chunks. By default, it splits by 1000 lines per output file. Output files are named with a prefix (default 'x') followed by a suffix like 'aa', 'ab', 'ac', etc. If no input file is given, split reads from standard input.

This is useful for breaking up large files to fit on removable media, distribute across systems, or process in parallel. Each output file can be recombined with cat.

Common options

FlagWhat it does
-b SIZESplit by bytes instead of lines (e.g., -b 1M for 1 megabyte chunks)
-l NUMSplit by number of lines per output file (default 1000)
-n NUMSplit into exactly NUM output files of equal size
-dUse numeric suffixes (00, 01, 02...) instead of alphabetic (aa, ab, ac...)
-xUse hexadecimal (base-16) numeric suffixes (00, 01... 0f, 10...)
--numeric-suffixes=FROMStart numeric suffix count from a specific number
-a LENGTHUse LENGTH characters for the suffix (default 2)
--filter=CMDPass each output file through CMD as a pipe (e.g., 'gzip')

Examples

Split large.txt into files of 100 lines each (chunk_aa, chunk_ab, etc.)

split -l 100 large.txt chunk_

Split data.iso into 10 MB pieces for portable distribution

split -b 10M data.iso part_ && ls part_*

Split input.txt into exactly 4 equally-sized files

split -n 4 input.txt output_

Split access.log by 500 lines with numeric suffixes (log_00, log_01...)

split -d -l 500 access.log log_

Split stdin (piped SQL dump) into 5000-line chunks

cat huge.sql | split -l 5000 - batch_

Split a 1GB disk image starting suffix numbering from 1 instead of 0

split -b 1G disk.img part_ --numeric-suffixes=1

Split and compress a backup in one pass using --filter would be cleaner alternative

split -b 100M backup.tar.gz - | gzip > backup.tar.gz.split

Split and compress each chunk automatically (creates log_aa.gz, log_ab.gz...)

split --filter='gzip > $FILE.gz' -b 50M large.log log_

Related commands