Linux (CentOS) splits files with split command

Source: Internet
Author: User

In Linux, a little attention is likely to produce a large volume of log files, even hundreds of m, drag down analysis is also a waste of time, this time, if you can cut the file into N small files, take the last file can see the recent log. There are some means, such as using the shell to generate logs on a daily basis, but not the scope of the discussion here. Lixin County Archives Bureau

The command to cut large files in CentOS is as follows:

View Source print?
1 split [OPTION] [INPUT [PREFIX]]

The options are as follows:

    • -A: Specify suffix length
    • -B: How many bytes per file
    • -D: Use a numeric suffix instead of a letter
    • -L: Specify the number of rows per file

For example I want to have suffix length 2, that is,-a 2. With the numeric suffix-d. 10M per file, i.e.-B 10m. The command can be designed as follows:

View Source print?
1 split -a 2 -d -b 10m /var/lib/mysql/general.lognowamagic

The following cut files are generated under the/root folder:

View Source print?
01 nowamagic00
02 nowamagic01
03 nowamagic02
04 nowamagic03
05 nowamagic04
06 nowamagic05
07 nowamagic06
08 nowamagic07
09 nowamagic08
10 nowamagic09

In addition to the last file is not 10M (it may be 10M, but the odds are very small), the others are.

Very understood, record here, convenient for people in need.

Linux (CentOS) splits files with split command

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.