Go Linux Split command detailed

Source: Internet
Author: User

Linux Split command detailed

Original: http://m.jb51.net/article/73632.htm

The Linux split command is used to divide a file into several, which splits large files into smaller files, which, by default, are cut into a small file per 1000 lines, with the basic syntax of split [--help][--version][-< rows >][- b < bytes >][-c < bytes >][-l < number of lines >][file to be cut [output file name].

command function : Cut files, cut files in units of behavior or in bytes

command Syntax :

Split [–help][–version]

Split [-< number of rows >][-l < rows;] [file to be cut] [output FILENAME]
, in number of rows

Split [-B < bytes >][-c < bytes;] [file to be cut] [output file name], in bytes

The output file name refers to a file that is then prefixed with the cut.

1. Cutting files in a behavioral unit

First create a 5-line file Hello,

#cat Hello
Hello, World1.
Hello, World2.
Hello, World3.
Hello, World4.
Hello, World5.

Use the command:

#split-2 Hello split1_

The split command cuts the file in two units, each consisting of a new file, and 5 rows with three files, each with the following names:

Split1_aa, Split1_ab, Split_ac

2. Cut in bytes

Or the file hello, using the command ls-l hello can see the size of the file is 65 bytes, cut the file with 10 bytes, there will be 7 files

Use the-B command first, as follows:

#split-B Hello split2_

There are 7 files cut out,

Split2_aa, Split2_ab, Split2_ac, Split2_ad, Split2_ae, Split2_af, Split2_ag

The following uses the-c parameter, as follows:

#split-C-Hello split3_

Cut out 10 files and output the following with the Ls-l command:

Although the file is also cut in bytes, but the-C parameter will try to maintain the integrity of each line, that is, a row has 13 bytes, then it will be cut into two files, a 10 byte, a 3 byte, and the-B parameter will accumulate 8 bytes to the next line to fill 10 bytes and then cut, so-b parameter only 7 files, The-c parameter has 10 files.

Go Linux Split command detailed

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.