split
Text processing
Usage
split -l 1000 [file] [prefix]Cuts a file into pieces; a header row stays only in the first piece, and the names end in aa, ab unless you pass -d for numbers.
Common flags
| Flag | Meaning |
|---|---|
| -l | How many lines per output file |
| -b | How many bytes per file, with suffixes such as 50M |
| -n | Cut into this many roughly equal pieces |
| -d | Number the pieces instead of naming them aa, ab |
| -a | How many characters the suffix has |
| --additional-suffix | GNU: give every piece an extension |
Examples
split -l 1000 big.csv part_Files part_aa, part_ab, 1000 lines each.
split -b 50M archive.tar chunk_Pieces of 50 MB.
cat chunk_* > archive.tarPuts the pieces back together.
These were built to be piped together. Three joined commands are usually shorter than one that does everything.
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 file into pieces; a header row stays only in the first piece, and the names end in aa, ab unless you pass -d for numbers.
Q. How do I type it?
split -l 1000 [file] [prefix] — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
6 are listed here; the full set is in man split. This command sits under Text processing.
Related commands
man page: man split