Name

split

Synopsis

    split [options] [infile] [outfile]

Split infile into several files of equal length. infile remains unchanged, and the results are written to outfile aa, outfile ab, etc. (default is xaa, xab, etc.). If infile is - (or missing), standard input is read. See also csplit.

Common Options

-n, -ln, --lines=n

Split infile into files, each n lines long (default is 1000).

-aslen, --suffix-length=slen

Use slen characters for the filename suffix. Default is 2.

-bn[m], --bytes=n[m]

Split into pieces of size n bytes. An optional multiplier m may be supplied: k for kilobytes and m for megabytes. GNU/Linux allows b for 512-byte blocks. Mutually exclusive with -l.

GNU/Linux Options

-Cbytes[m], --line-bytes=bytes[m]

Put a maximum of bytes into file; insist on adding complete lines. m is a multiplier: b for 512, k for 1024, and m for one megabyte.

-d, --numeric-suffixes

Use numeric file suffixes instead of alphabetic ones.

--verbose

Print a message for each output file.

Examples

Break bigfile into 1000-line segments:

    split bigfile

Join four files, then split them into ten-line files named new.aa, new.ab, etc. Note that without the -, new. would be treated as a nonexistent input file:

    cat list[1-4] | split -l 10 - new.

Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.