split
Archives
Usage
split -b <size> <file> <prefix>Cuts a big file into pieces; the default is by line count, 1000 at a time, so pass `-b 100M` when you meant size, the pieces are named xaa, xab and so on unless you give a prefix, and you glue them back with a single `cat part_* > file`, which works only because the suffixes sort in order.
Common flags
| Flag | Meaning |
|---|---|
| -b 100M | Pieces of a fixed size; K, M and G suffixes work on both platforms. |
| -l 1000 | Split by line count instead, which is the default behaviour at 1000 lines. |
| -n 4 | Cut into exactly four pieces. |
| -d | Numeric suffixes instead of aa, ab, ac. |
| -a 3 | Suffix length, when two letters are not enough. |
| --additional-suffix=.part | Append an extension to each piece. GNU only. |
| <prefix> | Optional, and without it the pieces are named xaa, xab, xac. |
Examples
split -b 100M big.tar.gz part_Produces part_aa, part_ab and so on.
cat part_* > big.tar.gzReassemble in glob order, which is why the suffixes are sorted.
split -l 5000 -d data.csv chunk_Five thousand lines per piece, with numeric suffixes.
Bundling and compressing are separate jobs: tar bundles, gzip shrinks, and .tar.gz is both.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does split do?
Cuts a big file into pieces; the default is by line count, 1000 at a time, so pass `-b 100M` when you meant size, the pieces are named xaa, xab and so on unless you give a prefix, and you glue them back with a single `cat part_* > file`, which works only because the suffixes sort in order.
Q. How do I type it?
split -b <size> <file> <prefix> — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
7 are listed here; the full set is in man split. This command sits under Archives.
Related commands
man page: man split