Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Split (Unix)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Usage== The command-[[syntax]] is: <syntaxhighlight lang="bash"> split [OPTION] [INPUT [PREFIX]] </syntaxhighlight> The default behavior of <code>split</code> 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 (Unix)|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 "<code>myfile.txt</code>" with exactly 3,000 lines of data: <syntaxhighlight lang="console"> $ head -3000 < /dev/urandom > myfile.txt </syntaxhighlight> Now, use the <code>split</code> command to break this file into pieces (note: unless otherwise specified, <code>split</code> will break the file into 1,000-line files): <syntaxhighlight lang="console"> $ 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 </syntaxhighlight> As seen above, the <code>split</code> command has broken the original file (keeping the original intact) into three, equal in number of lines (i.e., 1,000), files: <code>xaa</code>, <code>xab</code>, and <code>xac</code>.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)