Split (Unix)
| split | |
|---|---|
Example of split usage | |
| Original author | AT&T Bell Laboratories |
| Developers | Various open-source and commercial developers |
| Release | February 1973 |
| 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 on Unix, Plan 9, and Unix-like operating systems most commonly used to split a computer file into two or more smaller files.
History
The split command first appeared in Version 3 Unix[1] and is part of the X/Open Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX.1 and the Single Unix Specification.[2] The version of split bundled in GNU coreutils was written by Torbjorn Granlund and Richard Stallman.[3] The split command has also been ported to the IBM i operating system.[4]
Usage
The command-syntax is:
split [OPTION] [INPUT [PREFIX]]
The default behavior of split is to generate output files of a fixed size, default 1000 lines. The files are named by appending aa, ab, ac, etc. to output filename. If output filename is not given, the default filename of x is used, for example, xaa, xab, etc. When a hyphen (-) is used instead of input filename, data is derived from standard input. The files are typically rejoined using a utility such as cat.
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.
Split file into pieces
Create a file named "myfile.txt" with exactly 3,000 lines of data:
$ head -3000 < /dev/urandom > myfile.txt
Now, use the split command to break this file into pieces (note: unless otherwise specified, split will break the file into 1,000-line files):
$ split myfile.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 --lines xa*
1000 xaa
1000 xab
1000 xac
3000 total
As seen above, the split command has broken the original file (keeping the original intact) into three, equal in number of lines (i.e., 1,000), files: xaa, xab, and xac.
See also
- csplit – splits by content rather than by size
- File spanning
- List of Unix commands
References
- ^ – FreeBSD General Commands Manual
- ^ – Shell and Utilities Reference, The Single UNIX Specification, Version 5 from The Open Group
- ^ "split(1): split file into pieces - Linux man page". linux.die.net. Archived from the original on 2018-09-24. Retrieved 2019-01-24.
- ^ IBM. "IBM System i Version 7.2 Programming Qshell" (PDF). IBM. Archived (PDF) from the original on 2020-09-18. Retrieved 2020-09-05.
External links
- – Shell and Utilities Reference, The Single UNIX Specification, Version 5 from The Open Group
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.