Back to the command reference

split

FilesFundamentals In simulator In real Linux

Split a file into pieces

Name: split

You can practise it right away in the simulator, and use it in real Linux mode too.

Description

split cuts a large file into pieces by line count (-l) or size (-b), named xaa, xab … by default. cat them back together in order to restore it. Useful when transfers or storage have size limits.

Syntax

split [OPTION]... [FILE [PREFIX]]

Common options

-l / --lines NUMLines per output file
-b / --bytes SIZESize per output file, e.g. 100M
-n / --number CHUNKSSplit into CHUNKS equal parts
-dUse numeric suffixes
-a / --suffix-length NUse N characters for suffixes (2 by default: aa, ab, …)
--additional-suffix SUFFIXAdd SUFFIX to each name, e.g. .txt

Examples

  • $ split -l 1000 big.log part_

    One file per 1000 lines

    Explain
  • $ split -b 100M backup.tar.gz

    Split into 100 MB pieces

    Explain
  • $ cat part_* > big.log

    Join the pieces again

    Explain

Related