) Tar split package

Source: Internet
Author: User
In Linux, it is common to use the tar command to package and compress files. However, the Linux File System has a limit on the file size. That is to say, a file cannot exceed 2 GB. If the content of the compressed package is large, the final result will exceed 2 GB, so what should we do? Or if the compressed package needs to be backed up through a CD, and the size of each CD is only 700 mb, how should we store it? The solution is to split the final compressed package according to the specified size, which requires the split command.

Example:

To package and compress the logs directory and split it into multiple 1 m Files, run the following command:

Tar CJF-logs/| split-B 1 m-logs.tar.bz2.

The following files are generated:

-RW-r -- 1 httpd nobody 1048576 Oct 5 :37 logs.tar.bz2. AA

-RW-r -- 1 httpd nobody 1048576 Oct 5 :37 logs.tar.bz2. AB

-RW-r -- 1 httpd nobody 1048576 Oct 5 :37 logs.tar.bz2. AC

-RW-r -- 1 httpd nobody 1048576 Oct 5 :38 logs.tar.bz2. ad

-RW-r -- 1 httpd nobody 1048576 Oct 5 :38 logs.tar.bz2. AE

-RW-r -- 1 httpd nobody 829440 Oct 5 :39 logs.tar.bz2. af

In this way, the goal of storing the compressed package is achieved, but what should we do when we need to decompress the package? You just need to execute the following command:

Cat logs.tar.bz2. A * | tar XJ

Here we will explain some commands.

The red part of the compressed and split command line is the corresponding I/O file name parameter, where-indicates the standard input or output. .. The two then connect their standard input and output through the pipeline.

Here we will explain the parameter Meanings of the split command:

-B Size indicates the size of each file. The unit can be B (512 bytes), K (1 K), and M (1 m)

-D. Use numbers instead of letters as the suffix.

-A x indicates the length of the suffix. The default value is 2 characters.

In this way, the preceding command can be changed:

Tar CJF-logs/| split-B 1 m-D-A 1-logs.tar.bz2.

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.