| split | |
|---|---|
Example of split usage | |
| Original author | AT&T Bell Laboratories |
| Developers | Variousopen-source andcommercial developers |
| Initial release | February 1973; 52 years ago (1973-02) |
| Written in | C |
| Operating system | Unix,Unix-like,Plan 9,IBM i |
| Platform | Cross-platform |
| Type | Command |
| License | coreutils:GPLv3+ Plan 9:MIT License |
split is a utility onUnix,Plan 9, andUnix-likeoperating systems most commonly used to split acomputer file into two or more smaller files.
Thesplitcommand first appeared inVersion 3 Unix[1] and is part of theX/Open Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX.1 and theSingle Unix Specification.[2] The version ofsplit bundled inGNU coreutils was written by Torbjorn Granlund andRichard Stallman.[3] Thesplit command has also been ported to theIBM i operating system.[4]
The command-syntax is:
split[OPTION][INPUT[PREFIX]]
The default behavior ofsplit is to generate output files of a fixed size, default 1000 lines. The files are named by appendingaa,ab,ac, etc. tooutput filename. Ifoutput filename is not given, the default filename ofx is used, for example,xaa,xab, etc. When a hyphen (-) is used instead ofinput filename, data is derived fromstandard input. The files are typically rejoined using a utility such ascat.
Additional program options permit a maximum character count (instead of a line count), a maximum line length, how many incrementing characters in generated filenames, and whether to use letters or digits.
Create a file named "myfile.txt" with exactly 3,000 lines of data:
$head-3000</dev/urandom>myfile.txtNow, use thesplit command to break this file into pieces (note: unless otherwise specified,split will break the file into 1,000-line files):
$splitmyfile.txt$ls-l-rw-r--r-- 1 root root 761K Jun 16 18:17 myfile.txt-rw-r--r-- 1 root root 242K Jun 16 18:17 xaa-rw-r--r-- 1 root root 263K Jun 16 18:17 xab-rw-r--r-- 1 root root 256K Jun 16 18:17 xac$wc--linesxa* 1000 xaa 1000 xab 1000 xac 3000 total
As seen above, thesplit command has broken the original file (keeping the original intact) into three, equal in number of lines (i.e., 1,000), files:xaa,xab, andxac.
split(1) – FreeBSD General CommandsManualsplit – Shell and Utilities Reference,The Single UNIX Specification, Version 5 fromThe Open Groupsplit – Shell and Utilities Reference,The Single UNIX Specification, Version 5 fromThe Open Group