GNU Split: Examples and Reference

Last updated:

wip

Split is a very useful tool included in most Linux distributions. It can be used to split large files into smaller parts according to a variety of parameters:

Basic example

Default behaviour is to split file into parts containing 1000 lines

$ split largefile.txt

Split file into files each containing given number of lines

For example, have each part have 1 thousand lines:

$ split -l 1000 largefile.txt

Split file into files each containing given size (in bytes)

For example, 10MB

$ split largefile.txt -b 10MB

Split file into N equal-sized chunks

(Each chunk will have totalSize / N size)

For example, divide a large file into 10 parts

This may split files halfway through a line

$ split largefile.txt -n 10

Split files into N equal-sized chunks without splitting lines

Use l/N where N is the number of parts you want. This will only split files at line endings.

For example, divide a large file into 10 parts, each having 1/10 of the lines:

$ split largefile.txt -n l/10

See also

Dialogue & Discussion