linux下文件分割可以通過split命令來實(shí)現(xiàn),可以將一個(gè)大文件拆分成指定大小的多個(gè)文件,并且拆分速度非常的快,可以指定按行數(shù)分割和安大小分割兩種模式。Linux下文件合并可以通過cat命令來實(shí)現(xiàn),非常簡單。
在Linux下用split進(jìn)行文件分割
先看下幫助文檔
1
2
3
4
|
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. |
1
2
3
4
5
6
7
8
9
10
|
Mandatory arguments to long options are mandatory for short options too. -a, --suffix-length=N use suffixes of length N (default 2) 指定拆分文件的后綴長度 -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ù)
對與txt文本文件,可以通過指定分割后文件的行數(shù)來進(jìn)行文件分割。
命令:
1
|
split -l 300 large_file.txt new_file_prefix |
切分后默認(rèn)生成加后綴aa, ab, ac...以此類推, 當(dāng)然也可以自定義后綴。
模式二:指定分割后文件大小
1
|
split -b 10m server.log waynelog |
對二進(jìn)制文件我們同樣也可以按文件大小來分隔。
在Linux下用cat進(jìn)行文件合并
命令:
1
|
cat small_files* > large_file |
總結(jié)
以上就是本文關(guān)于Linux下文件的切分與合并的簡單方法介紹的全部內(nèi)容,希望對大家有所幫助。歡迎參閱本站Linux相關(guān):Linux中在防火墻中開啟80端口方法示例、Linux企業(yè)運(yùn)維人員常用的150個(gè)命令分享、淺談Linux的庫文件等,有什么問題盡管留言,有問題咱就改!
原文鏈接:http://www.pythontab.com/html/2017/linuxkaiyuan_0728/1159.html