Cutting large files (split)

split provides two ways to cut the file:
  • The number of cut lines, designated by the number of lines to be cut -l parameter
  • The size of the cut, cut to size by the need to specify parameter -b

1.1 In accordance with the number of lines cut

Follows with a 3.4G size of the log file to do cut the demo, each file to do cut to the 50000 line, specify the file called split-line, -d parameters are displayed digitally
Source file size # 
[@ VM_3_50_centos the root Split ] # LS -l 2020011702 -www.happylauliu.cn.gz - H
 -rw-R & lt - r-- . 1 the root the root . 3 .4G dated. 1   . 17  09 : 42 is  2020011702 - WWW. happylauliu.cn.gz 

# rows cutting 
[root @ ~] # Split the -l 50000 -d --verbose 2020011702 -www.happylauliu.cn.gz Split - line 
are creating a file " Split-line00 " 
are creating a file " split- Line01 " 
is to create the file "line02-Split " 
is to create the file " Split-line03 " 
are creating a file " Split-line04 " 
are creating a file " Split-line05 " 
are creating a file " Split-line06 " 
are creating a file " Split-line07 " 
are creating a file " split- line08 " 
are creating a file " Split-line09 " 
are creating a file " Split-line10 " 
... 
are creating a file " Split-line9168 " 
are creating a file " Split-line9169 "
Creating a file " Split-line9170" 
Creating a file " Split-line9171 " 

# view cutting the number of lines in the file to confirm 
[root @ VM_3_50_centos Split ] # WC the -l Split - line00
 50000  Split - line00 
[root @ VM_3_50_centos Split ] # WC the -l Split - Line01
 50000  Split - Line01 
[root @ VM_3_50_centos Split ] # WC the -l Split - line9170
 50000  Split - line9170 
[root @ VM_3_50_centos Split ] #WC the -l Split - line9171
 1020  Split - line9171 

# view the file size 
[root @ VM_3_50_centos Split ] # LS -LH Split -line0 [ 0 - 9 ]
 -rw-r - r-- 1 root root 14M Yue 1   17  16 : 54 is  Split - line00
 -rw-R & lt - r-- . 1 the root dated the root 14M. 1   . 17  16 : 54 is  Split - Line01
 -rw-R & lt - r-- . 1 the root dated the root 14M. 1   . 17  16 :54 split-line02
-rw-r--r-- 1 root root 14M 1月  17 16:54 split-line03
-rw-r--r-- 1 root root 14M 1月  17 16:54 split-line04
-rw-r--r-- 1 root root 14M 1月  17 16:54 split-line05
-rw-r--r-- 1 root root 14M 1月  17 16:54 split-line06
-rw-r--r-- 1 root root 14M 1月  17 16:54 split-line07
-rw-r--r-- 1 root root 14M 1月  17 16:54 split-line08
-rw-r--r-- 1 root root 14M 1月  17 16:54 split-line09
After the specified number of rows will automatically do the cutting, that is, to achieve automatic cutting after 5000 rows will be automatically digitally named by -d parameter file name, after cutting, each file size is 14M, then this time will be on file for analysis many convenience border, while the number of files will be a lot of ways you can increase the number of lines cut, convenient analysis.

1.2 The size of the cut

In addition to cutting in accordance with the number of rows, Split supports file size by cutting, cutting by specifying the -b parameter specifies file size, file size support units K, M, G, T, P, E, Z, as follows to cut 500M presentations cutting process
[root @ ~] # Split -b 500M --verbose -d 2,020,011,702 -www.happylauliu.cn.gz Split - size 
are creating a file " Split-size00 " 
are creating a file " Split-size01 " 
are creating a file " Split-size02 " 
Creating a file " Split-size03 " 
are creating a file " Split-size04 " 
are creating a file " Split-size05 " 
are creating a file " Split-size06 "

[root@VM_3_50_centos split]# ls -lh split-size0*
-rw-r--r-- 1 root root 500M 1月  17 17:03 split-size00
-rw-r--r-- 1 root root 500M 1月  17 17:03 split-size01
-rw-r--r-- 1 root root 500M 1月  17 17:04 split-size02
-rw-r--r-- 1 root root 500M 1月  17 17:04 split-size03
-rw-r--r-- 1 root root 500M 1月  17 17:04 split-size04
-rw-r--r-- 1 root root 500M 1月  17 17:04 split-size05
-rw-r--r-- 1 root root 444M 1月  17 17:04 split-size06

More than 130 file merge

split a large file users will be cut into multiple small files, if multiple small files into one file you need to how to deal with it? You can use file redirection manner, following the presentation of two small files into one file

[root@VM_3_50_centos split]# cat split-size01 split-size02 >two-file-merge

[root@VM_3_50_centos split]# ls -lh two-file-merge
-rw-r--r-- 1 root root 1000M 1月  17 17:20 two-file-merge

Merger by reading the file the way + output redirection, be problematic for large file performance, we are proposed to use as needed.

Guess you like

Origin www.cnblogs.com/kcxg/p/12324854.html