split — Split a file
Linux / Basic Linux commands / split.html
Splits a large file into pieces by size or line count.
Basic Information
| Command Name | split |
|---|---|
| One-line Introduction | Splits a large file into pieces by size or line count. |
| Provided by | GNU coreutils |
| Official Documentation | https://man7.org/linux/man-pages/man1/split.1.html |
| Supported Operating Systems | Linux, macOS, BSD, WSL |
| Installation Status | Installed by default |
| Category | Linux basic commands (tags: Linux basic commands (tags: split, split file, chunk, large file)) |
What is this command?
split divides an input file into pieces named xaa, xab and so on, by line count (-l) or byte size (-b). The pieces can be concatenated back with cat.
Use -d for numeric suffixes, -a for suffix length and --additional-suffix for extensions. It is commonly used to cut logs into transfer-friendly chunks.
What problems does it solve?
- Cutting large logs into transferable chunks
- Splitting input for parallel processing
- Meeting attachment size limits
- Reassembling pieces into the original file
Key features
Split by size
The -b option sets a byte size.
- When to use: Cutting files for transfer
- What you get: Pieces have a predictable size.
- Limitations: Pieces may split in the middle of a line.
Split by lines
The -l option sets a line count.
- When to use: Dividing text into logical blocks
- What you get: Line boundaries stay intact.
- Limitations: Piece sizes vary.
Naming
-d, -a and --additional-suffix control names.
- When to use: When later scripts depend on names
- What you get: Sorting and extensions stay consistent.
- Limitations: Existing files may be overwritten.
Installation and usage
Check whether it is installed
split --version
sudo apt install coreutils # Debian/Ubuntu sudo dnf install coreutils # Fedora
Real-world examples
Split by lines
Split every 1000 lines.
split -l 1000 app.log part-
Split by size
Split into 10MB pieces.
split -b 10M backup.tar.gz backup-
Reassemble
Concatenate pieces in order.
cat part-* > app.log