On Unix-like operating systems, the split command splits a file into pieces.
This page covers the GNU/Linux version of split.
Description
split outputs fixed-size pieces of input INPUT to files named PREFIXaa, PREFIXab, …
- Description
- Syntax
- Examples
- Related commands
- Linux commands help
The default size for each split file is 1000 lines, and default PREFIX is “x”. With no INPUT, or when INPUT is a dash ("-"), read from standard input.
Syntax
split [OPTION]… [INPUT [PREFIX]]
Options
SIZE may be one of the following, or an integer optionally followed by one of following multipliers:
…and so on for G (gigabytes), T (terabytes), P (petabytes), E (exabytes), Z (zettabytes), Y (yottabytes).
CHUNKS may be:
- N: split into N files based on size of input
- K/N: output Kth of N to standard output
- l/N: split into N files without splitting lines
- l/K/N: output Kth of N to standard output without splitting lines
- r/N: like “l” but use round robin distribution r/K/N likewise but only output Kth of N to standard output
Examples
split -b 22 newfile.txt new
Split the file newfile.txt into three separate files called newaa, newab and newac…, with each file containing 22 bytes of data.
split -l 300 file.txt new
Split the file newfile.txt into files beginning with the name new, each containing 300 lines of text.
Related commands
csplit — Split files based on a defined context.