CentOS uses the split command to split the file instance

  

The split command in Linux system is mainly used for file splitting. It is often used when dealing with large files. The following small series will introduce you to CentOS how to use split command to split files. Let's get to know it.

In Linux, there may be a little not pay attention to a huge volume of log files, even hundreds of M, dragged down analysis is a waste of time, this time, if the file can be cut N small files, you can see the most recent log with the last file.

There are some means, such as using the shell to generate logs every day, etc., but not the scope of this discussion.

The commands for cutting large files in CentOS are as follows:

The code is as follows:

split [OPTION] [INPUT [PREFIX]]

The options are as follows: Br>

•-a : Specify the length of the suffix

•-b : How many bytes per file

•-d : Use a numeric suffix instead of a letter

•-l : Specify the number of lines per file

For example, the system home Xiaobian wants the suffix length to be 2, which is -a 2. Use the numeric suffix -d. 10M per file, ie -b 10m. The command can be designed as follows:

The code is as follows:

split -a 2 -d -b 10m /var/lib/mysql/general.log nowamagic

will be in /root The following cut file is generated under the folder:

The code is as follows:

nowamagic00

nowamagic01

nowamagic02

nowamagic03

nowamagic04

nowamagic05

nowamagic06

nowamagic07

nowamagic08

nowamagic09

except for the last file is not 10M (It may be just 10M, but the chances are small), the others are.

The above is how CentOS uses the split command to split files. If you want to move a large file, or if the analyzed log is large, you can try splitting with the split command.

Copyright © Windows knowledge All Rights Reserved