Linux split large file instances

Source: Internet
Author: User

The split function is used to split files in linux. Its main function is to split large folders. Next I will introduce some examples of splitting large files.

Linux split command

Function Description: cut a file.

Syntax: split [-- help] [-- version] [-<number of rows>] [-B <byte>] [-C <byte>] [-l <number of rows>] [To cut file] [output file name]

Note: split can cut the file into smaller files. By default, each 1000 lines can be cut into a smaller file.

Parameters:

-<Number of rows> or-l <number of rows> specifies the number of rows to be split into a small file.

-B <byte> specifies the number of characters to be split into a small file. Supported units: m, k

-C <byte> is similar to the-B parameter, but the integrity of each line should be maintained whenever possible during cutting.

-- Help: displays help.

-- Version: displays the version information.

[Output file name] sets the prefix file name of the cut file. split will automatically add a number after the prefix file name.

Use split in Linux to split files:

Mode 1: specify the number of lines of files after segmentation

For text files, you can specify the number of lines of the split files to split the files.

Command: split-l 300 large_file.log new_file_prefix

Mode 2: Specify the split File Size

The Code is as follows: Copy code

Split-B 10 m server. log server_prefix

We can also separate binary files by file size.

Split file.tar.gz into a file with the "file _" prefix and 10 MB in size.

The Code is as follows: Copy code
$ Split-B 10 m file.tar.gz file _

Merge files with cat in Linux:

Command: cat small_files *> large_file

Merge and split files

The Code is as follows: Copy code

$ Cat file _ *> file.tar.gz

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.