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