linux下文件分割可以通過(guò)split命令來(lái)實(shí)現(xiàn),可以將一個(gè)大文件拆分成指定大小的多個(gè)文件,并且拆分速度非常的快,可以指定按行數(shù)分割和安大小分割兩種模式。linux下文件合并可以通過(guò)cat命令來(lái)實(shí)現(xiàn),非常簡(jiǎn)單。
在Linux下用split進(jìn)行文件分割
先看下幫助文檔
Usage: split [OPTION]… [INPUT [PREFIX]]
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.
Mandatory arguments to long options are mandatory for short options too.
? -a, –suffix-length=N ? use suffixes of length N (default 2) 指定拆分文件的后綴長(zhǎng)度
? -b, –bytes=SIZE ? ? ? ?put SIZE bytes per output file 按字節(jié)拆分,默認(rèn)單位字節(jié)
? -C, –line-bytes=SIZE ? put at most SIZE bytes of lines per output file ?指定單行的最大大小,默認(rèn)單位字節(jié)
? -d, –numeric-suffixes ?use numeric suffixes instead of alphabetic 用數(shù)字作為拆分文件的后綴
? -l, –lines=NUMBER ? ? ?put NUMBER lines per output file ?按行數(shù)進(jìn)行拆分
? ? ? –verbose ? ? ? ? ? print a diagnostic just before each
? ? ? ? ? ? ? ? ? ? ? ? ? ? output file is opened
? ? ? –help ? ? display this help and exit
? ? ? –version ?output version information and exit
模式一:指定分割后文件行數(shù)
對(duì)與txt文本文件,可以通過(guò)指定分割后文件的行數(shù)來(lái)進(jìn)行文件分割。
命令:
split?-l?300?large_file.txt?new_file_prefix
切分后默認(rèn)生成加后綴aa, ab, ac…以此類(lèi)推, 當(dāng)然也可以自定義后綴。
模式二:指定分割后文件大小
split?-b?10m?server.log?waynelog
對(duì)二進(jìn)制文件我們同樣也可以按文件大小來(lái)分隔。
在Linux下用cat進(jìn)行文件合并
命令:
cat?small_files*?>?large_file