Linux 大文件分隔与合并

Linux 大文件分割

按行分割

语法:

$ split -l 200 [大文件名称] [文件前缀]

示例: 按每 3 行分割 test.txt 文件,分隔后的前缀为 split_test_,分割后的文件结尾以 0 开始

# split -l 3 -d test.txt split_test_
# ll | grep split_test
输出结果为:
-rw-r--r-- 1 root root      39 6月  28 19:10 split_test_00
-rw-r--r-- 1 root root      54 6月  28 19:10 split_test_01
-rw-r--r-- 1 root root      94 6月  28 19:10 split_test_02
-rw-r--r-- 1 root root     218 6月  28 19:10 split_test_03
-rw-r--r-- 1 root root      62 6月  28 19:10 split_test_04

-l: 是 L 的小写,表示行数;
-d: 表示以数字结尾;
-split_test_: 表示分割后的文件前缀

按照大小分隔

语法:

split -b [分割大小] [大文件名称] [前缀]

示例:按每 10M 分割 test.txt 文件,分隔后的前缀为 split_test_,分割后的文件结尾以 0 开始

split -b 10m -d test.txt split_test_

将分割后的文件进行合并

采用 cat 命令对分割后的文件进行合并

cat split_test_* > merge_test.txt

猜你喜欢

转载自blog.csdn.net/dejunyang/article/details/94036654