The split
command is used to split a large file into smaller files. By default, it splits the file into smaller files with 1000
lines in each file.
split [OPTION]... [FILE [PREFIX]]
-a, --suffix-length=N
: Use suffixes of lengthN
, by default use 2 characters.--additional-suffix=SUFFIX
: Append an additionalSUFFIX
to the file names.-b, --bytes=SIZE
: PutSIZE
bytes per output file.-C, --line-bytes=SIZE
: Put at mostSIZE
bytes of lines into each output file, similar to-b
but with consideration for maintaining line integrity.-d
: Use numeric suffixes instead of alphabetic.--numeric-suffixes[=FROM]
: Same as-d
, but allows setting a start value.-e, --elide-empty-files
: Do not generate empty output files with-n
.--filter=COMMAND
: Write to shellCOMMAND
; file name is$FILE
.-l, --lines=NUMBER
: PutNUMBER
lines per output file.-n, --number=CHUNKS
: GenerateCHUNKS
output files;CHUNKS
could be:N
: split intoN
files based on input sizeK/N
: outputK
th ofN
to stdoutl/N
: split intoN
files, no line splittingl/K/N
: outputK
th ofN
to stdout, no line splittingr/N
: similar tol
, but use a round robin distributionr/K/N
: outputK
th ofN
to stdout, with round robin distribution
-t, --separator=SEP
: UseSEP
instead of newline as the record separator,\0
forNUL
.-u, --unbuffered
: Immediately copy input to output with-n r/...
.--verbose
: Print informative message before opening each output file.--help
: Display help information.--version
: Output version information.
Split file tmp/file.txt
into separate files, named newaa
, newab
, newac
, etc., with each file containing 2 bytes of data.
split -b 2 /tmp/file.txt new
Split file tmp/file.txt
into separate files, named newaa
, newab
, newac
, etc., with each file containing 2 lines of data.
split -l 2 /tmp/file.txt new
Split file tmp/file.txt
into separate files, using numeric suffixes, with each file containing 2 lines of data.
split -d -l 2 /tmp/file.txt new
https://github.com/WindrunnerMax/EveryDay
https://www.computerhope.com/unix/usplit.htm
https://www.runoob.com/linux/linux-comm-split.html
https://www.tutorialspoint.com/unix_commands/split.htm