Linux common commands: split command

  split is a commonly used command to split files under linux. File division under Linux can be achieved by the split command, and cat is used for file merging. The split can specify two modes: split by the number of lines and split by size.

1. Command format:

  split [OPTION]... [file to split [PREFIX]]

  split [--help][--version][-<lines>][-b <bytes>][-C <bytes>][-l <lines>][files to split][output file name]

2. Command function:

  Split a file into many smaller files

3. Common parameters:

-b: output file suffix length

-b <byte>: The value is the size of each output file, in bytes.

-C<byte>: The maximum number of bytes in a single line in each output file.

-d: Use a number as the (output file) suffix.

-l<number of lines>: The value is the number of lines in each output file.

PREFIX: represents the leading character, which can be used as the leading file of the cutting file.

[Output file name] Set the pre-file name of the file after cutting, and split will automatically add a number to the pre-file name.

4. Common examples:

Example 1: Divide a file in row units

Order:

  split -l 1000000 -d filename.txt splitfile_

Description: Take a split file filename.txt for every 1 million rows, and the split file is splitfile_+digital suffix as the file name, such as: splitfile_000, splitfile_001, splitfile_002,...

 

Example 2: Cut a file in bytes

Order:

  split -b 10  -d filename.txt splitfle_

Description: Each 10 bytes (byte) is divided into a file

 

Example 3: Specify the file name after segmentation

Order:

  split -b 10k filename.txt -d -a 3 splitfile_

Description: Take every 10k as a split file, and the obtained file takes splitfile_ plus 3 digits as the file name, such as: splitfile_000, splitfile_001, splitfile_002, ...

 



Guess you like

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