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
,-l
n
,--lines=
n
Split infile into files, each n lines long (default is 1000).
-a
slen
,--suffix-length=
slen
Use slen characters for the filename suffix. Default is 2.
-b
n
[
m
],--bytes=
n
[
m
]Split into pieces of size n bytes. An optional multiplier m may be supplied:
k
for kilobytes andm
for megabytes. GNU/Linux allowsb
for 512-byte blocks. Mutually exclusive with-l
.
GNU/Linux Options
-C
bytes
[
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, andm
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.