linux/197793.html">linux/197197.html">linux下文件分割可以通過split命令來實現(xiàn),可以將一個大文件拆分成指定大小的多個文件,并且拆分速度非常的快,可以指定按行數(shù)分割和安大小分割兩種模式。Linux下文件合并可以通過cat命令來實現(xiàn),非常簡單。
在Linux下用split進行文件分割
先看下幫助文檔
Usage: split [OPTION]... [INPUT [PREFIX]]Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab, ...; defaultsize is 1000 lines, and default PREFIX is `x'. With no INPUT, or when INPUTis -, 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) 指定拆分文件的后綴長度 -b, --bytes=SIZE put SIZE bytes per output file 按字節(jié)拆分,默認單位字節(jié) -C, --line-bytes=SIZE put at most SIZE bytes of lines per output file 指定單行的最大大小,默認單位字節(jié) -d, --numeric-suffixes use numeric suffixes instead of alphabetic 用數(shù)字作為拆分文件的后綴 -l, --lines=NUMBER put NUMBER lines per output file 按行數(shù)進行拆分 --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ù)來進行文件分割。
命令:
split -l 300 large_file.txt new_file_prefix
切分后默認生成加后綴aa, ab, ac...以此類推, 當然也可以自定義后綴。
模式二:指定分割后文件大小
split -b 10m server.log waynelog
對二進制文件我們同樣也可以按文件大小來分隔。
在Linux下用cat進行文件合并
命令:
cat small_files* > large_file
總結(jié)
以上就是本文關(guān)于Linux下文件的切分與合并的簡單方法介紹的全部內(nèi)容,希望對大家有所幫助。有什么問題盡管留言,有問題咱就改!
新聞熱點
疑難解答
圖片精選