Processing large file segmentation in Linux

Source file a.txt

a
b
c
d
e
f

View the number of lines in the file:

wc -l a.txt 

执行后结果
6 a.txt

Use the split command to split files according to the number of lines

split -l 2 a.txt -d -a 4 b

执行后结果
b_0000
b_0001
b_0002
解释:
将a.txt文件按照2行来平分成若干个大小文件,b_ 是要保存成的新文件的前缀,后缀是指定的4位数字

Use split command to split files according to file size

split -b 10m a.txt b

#将a.txt分割分割成大小为10m的多个文件

Guess you like

Origin blog.csdn.net/qq_38220334/article/details/114117148