split(1)
Split a file into smaller pieces by lines, bytes, or patterns.
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
| Flag | What it does |
|---|---|
-b SIZE | Split by bytes instead of lines (e.g., -b 1M for 1 megabyte chunks) |
-l NUM | Split by number of lines per output file (default 1000) |
-n NUM | Split into exactly NUM output files of equal size |
-d | Use numeric suffixes (00, 01, 02...) instead of alphabetic (aa, ab, ac...) |
-x | Use hexadecimal (base-16) numeric suffixes (00, 01... 0f, 10...) |
--numeric-suffixes=FROM | Start numeric suffix count from a specific number |
-a LENGTH | Use LENGTH characters for the suffix (default 2) |
--filter=CMD | Pass 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=1Split and compress a backup in one pass using --filter would be cleaner alternative
split -b 100M backup.tar.gz - | gzip > backup.tar.gz.splitSplit and compress each chunk automatically (creates log_aa.gz, log_ab.gz...)
split --filter='gzip > $FILE.gz' -b 50M large.log log_