Linux - file splitting (split)

There are two file cutting modes: text file and binary mode.

1. Text mode
Text mode is only applicable to text files, and each file cut with this mode is readable. There are two types of text modes: cut by maximum file size and cut by lines of text.

  1) Cut by file size

                split -C 50k log.log splog

Divide the text file log.log into a maximum size of 50k per block without breaking lines. The output file names are like splogaa, slogab... 

   2) Cut by the number of lines of text

                split -l 100 log.log splog

100 lines per chunk, regardless of size. Should be useful for log analysis.

2. Binary mode

                split -b 50k log.log splog

 Each chunk (of course, the last one is not guaranteed) is 50k in size, basically unreadable. Any type of file can use this cutting mode.

 

 

split parameter:

        -a: Specifies the suffix length of the output file name, the default is 2 (aa, ab...)

        -d: The suffix of the specified output file name is replaced by a number

        -b: Specify the maximum number of bytes of the output file, such as 1k, 1m...
        -C: Specify the maximum number of bytes of a single line in each output file

        -l: specifies the maximum number of lines per output file

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326549745&siteId=291194637