split — Split a file into manageable pieces

Format

split [–a n] [–l n] [file [prefix]]
split –b n[bkm] [–a n] [file [prefix]]
split [n] [–a n] file [prefix]

Description

split breaks up a file into a set of files. It starts a new file every time it has copied 1000 lines.

split names the files that it creates as a prefix followed by a suffix. x is the prefix unless you specify a different prefix on the command line. Unless altered by the following options, the suffix begins as aa and is incremented with each new file. By default, therefore, the first file is xaa followed by xab, and so on.

Options

–a n
Uses a suffix n letters long. The default is two.
–b n[bkm]
Splits the file every n units. The default unit size is bytes. When you follow n with b, k, or m, split uses a corresponding unit size of 512 bytes, 1K (1024 bytes), or 1 megabyte (1 048 576 bytes).
–l n
Splits the file every n lines.
n
Is an obsolete version of the –l option.

If the file is (dash) or if no file is specified, split reads the standard input (stdin).

Localization

split uses the following localization environment variables:
  • LANG
  • LC_ALL
  • LC_CTYPE
  • LC_MESSAGES
  • NLSPATH

See Localization for more information.

Exit values

0
Successful completion
1
Failure due to any of the following:
  • Error opening input or output file
  • Missing number after –a
  • Incorrect –a option
  • Missing byte count after –b
  • Invalid byte count specification
  • Invalid count specification
  • Unknown option
  • Out of memory for binary split buffer
  • Read error on input file
  • Write error on output file
  • Too many names generated

Portability

POSIX.2 User Portability Extension, X/Open Portability Guide, UNIX systems,

The b suffix of the –b option is an extension to the POSIX.2 standard.

Related information

csplit