Linux -- split 文件分割操作
SPLIT(1) User Commands SPLIT(1)
NAME 名称
split - split a file into pieces 分割文件成多个碎片
SYNOPSIS 概要(语法)
split [OPTION]... [INPUT [PREFIX]]
DESCRIPTION 说明
Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab, ...; default size is 1000 lines, and default PREFIX is 'x'. With no INPUT, or when INPUT is -, read standard input.
将输入内容输出成固定大小的输出文件,格式如:PREFIXaa, PREFIXab, ...;默认大小为1000行,默认前缀是"x",当没有指定输入或输入是"-"时,从标准输入读取。
Mandatory arguments to long options are mandatory for short options too.
对于长选项必须的参数,对于短选项也是必须的。
-a, --suffix-length=N
generate suffixes of length N (default 2)
使生成的后缀长度为N,默认为2。
--additional-suffix=SUFFIX
append an additional SUFFIX to file names
追加一个额外的字符串作为文件名的后缀。
-b, --bytes=SIZE
put SIZE bytes per output file
写入SIZE大小到每个输出文件,只有最后一个文件大小<=SIZE。
Ruby代码 收藏代码
# ll
total 672
-rw-r----- 1 root root 681710 Feb 27 15:59 catalina.out
# split -b 100K catalina.out
# ll
total 1368
-rw-r----- 1 root root 681710 Feb 27 15:59 catalina.out
-rw-r--r-- 1 root root 102400 Feb 27 16:37 xaa
-rw-r--r-- 1 root root 102400 Feb 27 16:37 xab
-rw-r--r-- 1 root root 102400 Feb 27 16:37 xac
-rw-r--r-- 1 root root 102400 Feb 27 16:37 xad
-rw-r--r-- 1 root root 102400 Feb 27 16:37 xae
-rw-r--r-- 1 root root 102400 Feb 27 16:37 xaf
-rw-r--r-- 1 root root 67310 Feb 27 16:37 xag
#
-C, --line-bytes=SIZE
put at most SIZE bytes of lines per output file
每个输出文件至多写入SIZE字节,以记录为单位,生成的每个文件都<=SIZE。
Ruby代码 收藏代码
#
# ll
total 672
-rw-r----- 1 root root 681710 Feb 27 15:59 catalina.out
# split -C 100K catalina.out
# ll
total 1368
-rw-r----- 1 root root 681710 Feb 27 15:59 catalina.out
-rw-r--r-- 1 root root 102392 Feb 27 16:36 xaa
-rw-r--r-- 1 root root 102357 Feb 27 16:36 xab
-rw-r--r-- 1 root root 102203 Feb 27 16:36 xac
-rw-r--r-- 1 root root 102346 Feb 27 16:36 xad
-rw-r--r-- 1 root root 102384 Feb 27 16:36 xae
-rw-r--r-- 1 root root 102387 Feb 27 16:36 xaf
-rw-r--r-- 1 root root 67641 Feb 27 16:36 xag
#
-d, --numeric-suffixes[=FROM]
use numeric suffixes instead of alphabetic; FROM changes the start value (default 0)
使用数字代替字母后缀,FROM指定数字的起始位置,默认从0开始。
Ruby代码 收藏代码
# ll
total 672
-rw-r----- 1 root root 681710 Feb 27 15:59 catalina.out
# split -l 50000 catalina.out
# ll
total 1344
-rw-r----- 1 root root 681710 Feb 27 15:59 catalina.out
-rw-r--r-- 1 root root 681710 Feb 27 16:38 xaa
# rm -rf xaa
# split -l 50000 -d catalina.out
# ll
total 1344
-rw-r----- 1 root root 681710 Feb 27 15:59 catalina.out
-rw-r--r-- 1 root root 681710 Feb 27 16:38 x00
#
-e, --elide-empty-files
do not generate empty output files with '-n'
结合-n使用,不生成空的输出文件。
--filter=COMMAND
write to shell COMMAND; file name is $FILE
将结果作为COMMAND的输入,类似于管道符。
-l, --lines=NUMBER
put NUMBER lines per output file
写入Number行到每个输出文件,最后一个文件<=NUMBER行。
-n, --number=CHUNKS
generate CHUNKS output files; see explanation below
使生成CHUNKS输出文件,说明见后。
-u, --unbuffered
immediately copy input to output with '-n r/...'
将输入立即写入到输出文件,结合-n r/...使用。
--verbose
print a diagnostic just before each output file is opened
在打开或创建每个输出文件前,打印诊断信息。
--help display this help and exit
显示此命令的帮助信息并退出
--version
output version information and exit
输入版本信息并退出
SIZE is an integer and optional unit (example: 10M is 10*1024*1024). Units are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000).
SIZE参数是一个整数,亦是可选参数(例子:10M = 10*1024*1024).单数包括K, M, G, T, P, E, Z, Y(进制是1024)或者是KB, MB, ...(进制是1000)。
CHUNKS may be: N split into N files based on size of input K/N output Kth of N to stdout l/N split into N files without splitting lines l/K/N output Kth of N to stdout without splitting lines r/N like 'l' but use round robin distribution r/K/N likewise but only output Kth of N to stdout
N split into N files based on size of input
基于大小将输入分成N份
K/N output Kth of N to stdout
将输入基于大小分成N份,将第K份打印
l/N split into N files without splitting lines
基于大小将输入分成N份,但不截断行,有断行往前补齐
l/K/N output Kth of N to stdout without splitting lines
将输入基于大小分成N份,将第K份打印,但不截断行,有断行往前补齐
r/N like 'l' but use round robin distribution
同l,使用循环分配
r/K/N likewise but only output Kth of N to stdout
同l,使用循环分配,分成N份,将第K份打印,但不截断行,有断行往前补齐
GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Report split translation bugs to <http://translationproject.org/team/>
AUTHOR
Written by Torbjorn Granlund and Richard M. Stallman.
COPYRIGHT
Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
SEE ALSO
The full documentation for split is maintained as a Texinfo manual. If the info and split programs are properly installed at your site, the command info coreutils 'split invocation' should give you access to the complete manual.
split的完整文档是以Texinfo手册形式维护的。如果info和split程序都已经安装,那么执行命令:
info coreutils 'split invocation'
应该会让你访问到整篇手册。
GNU coreutils 8.22 June 2014 SPLIT(1)