Use split to cut by number of lines under Linux

Source: Internet
Author: User

Description: In general, split cuts by number of rows are mostly used on log files.

Instance:

Divide a large file into several small file methods:

For example, a BLM.txt file is divided into 1000 small files prefixed with blm_, with a suffix of factor form and a suffix of 4 digits

1, first Use

Wc

read out how many lines of BLM.txt file there are

Re-use the split command

Split 2482 4 Blm_

BLM.txt the file into several small files, 2482 lines per file (-l 2482), file prefix is blm_, the coefficient is not a letter but a number (-D), the suffix factor is four digits (-a 4)

Unfortunately, the file can not be a suffix can not be blm_*.text to achieve, the result can only be blm_0000. However, it can be processed on its own, such as batch renaming:

' s/$//.txt/ '

Use Rename to rename any file in the current directory to a. txt extension.

In addition to cutting files, there are also merge files, using the cat command:

Cat Blm_* >blm.txt

You are using the Cat command.

Reference:

http://blog.csdn.net/jkunzhang/article/details/7666398

https://www.cnblogs.com/AloneSword/p/5072698.html (Rename usage)

Http://man.linuxde.net/split (split usage)

Http://man.linuxde.net/cat (cat usage)

Use split to cut by number of lines under Linux

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.