Linux in a Nutshell, Third Edition
by Ellen Siever, Stephen Spainhour, Jessica P. Hekman, Stephen Figgins
Name
split
Synopsis
split [option] [infile] [outfile]
Description
Split infile into equal-sized segments. infile remains unchanged, and the results are written to outfile aa, outfile ab, and so on. (default is xaa, xab, etc.). If infile is - (or missing), standard input is read. See also csplit.
Options
- -n, -l n, --lines= n
Split infile into n-line segments (default is 1000).
- -b n[bkm], --bytes= n[bkm]
Split infile into n-byte segments. Alternate blocksizes may be specified:
- b
512 bytes
- k
1 kilobyte
- m
1 megabyte
- -C bytes[bkm], --line-bytes= bytes[bkm]
Put a maximum of bytes into file; insist on adding complete lines.
- --help
Print a help message and then exit.
- --verbose
Print a message for each output file.
- --version
Print version information and then exit.
- -
Take input from the standard input.
Examples
Break bigfile into 1000-line segments:
split bigfileJoin four files, then split them into 10-line files named new.aa, new.ab, and so on. Note that without the -, new. would be treated as a nonexistent input file:
cat list[1-4] | split -10 - new.Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access