linux 文件拆分 合并,Linux下文件的切分与合并的简单方法
linux下文件分割可以通過split命令來實現,可以將一個大文件拆分成指定大小的多個文件,并且拆分速度非常的快,可以指定按行數分割和安大小分割兩種模式。Linux下文件合并可以通過cat命令來實現,非常簡單。
在Linux下用split進行文件分割
先看下幫助文檔
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) 指定拆分文件的后綴長度
-b, --bytes=SIZE ? ? ? ?put SIZE bytes per output file 按字節拆分,默認單位字節
-C, --line-bytes=SIZE ? put at most SIZE bytes of lines per output file ?指定單行的最大大小,默認單位字節
-d, --numeric-suffixes ?use numeric suffixes instead of alphabetic 用數字作為拆分文件的后綴
-l, --lines=NUMBER ? ? ?put NUMBER lines per output file ?按行數進行拆分
--verbose ? ? ? ? ? print a diagnostic just before each
output file is opened
--help ? ? display this help and exit
--version ?output version information and exit
模式一:指定分割后文件行數
對與txt文本文件,可以通過指定分割后文件的行數來進行文件分割。
命令: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
總結
以上是生活随笔為你收集整理的linux 文件拆分 合并,Linux下文件的切分与合并的简单方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 程序员与动漫
- 下一篇: 自定义快捷命令程序(VC++加批处理)