Linux Tar Split Compression decompression piecewise compression decompression __linux

Source: Internet
Author: User
Tags bz2

Tar cjf/home/data/ai-new/packets/| Split-b 1000m-tt.tar.bz2
Cat tt.tar.bz2.a* > tt.tar.bz2

Tar czf xx.tar.gz/home/dd
Tar xvf xx.tar.gz/home/dd


To specify an extract directory by using-C

TAR-ZXVF eclipse-jee-indigo-sr2-linux-gtk-x86_64.tar.gz-c/usr

tar is a file packaging tool, split is a file segmentation tool, when sending attachments in a message, may be due to attachment size restrictions, need to compress and split, several messages sent. When you need to back up a lot of data, a single file that is packaged may exceed a single file size limit that the file system supports, and you need to split it into a suitable size package. Just have to back up the Skype folder today, so use this example to illustrate the tar and split two instructions, how to compress, split, and then through the cat merged split file decompression restore, as well as in the pipeline "|" The process of packing and separating files with the combination.

For example: My. Skype files are already 35M, and now you need to compress them up and package them directly with tar :

Compress files with tar :
[Marco.chan@linuxhobby backup]$ ls
Skype_backup
[Marco.chan@linuxhobby backup]$ tar -czvp-f skype_backup. Tar. GZ skype_backup
The middle packing compression output process omits ...
Skype_backup/marco.chan.skype/chat512.dbb
Skype_backup/marco.chan.skype/user4096.dbb
Skype_backup/marco.chan.skype/chatmsg256.dbb
Skype_backup/shared.xml
Skype_backup/shared.lck
[Marco.chan@linuxhobby backup]$ ls
Skype_backup. tar. GZ skype_backup

Because the "-V" parameter is used, the file information in the middle is printed with the packaged compression.
-C (Create) Of course is to create a packaging file.
-Z (GZIP) invokes gzip for compression, with the recommended suffix named *. tar. gz; You can also use-j (bzip2) and suggest a suffix named *. tar. bz2.
-P (preserve-permissions) lowercase p, which retains the original file attribute, which is the rwx attribute.
The-f (file) Output target file "Skype_backup. tar. GZ "will be processed by the source file" Skype_backup ", can be-f ligatures, but for easy to remember and distinguish, so here is written separately.

The skype_backup after packing. tar. GZ also has a 15M size, but my mail attachment supports the 6M size, so it has to be split.

Splite split file :
[marco.chan@linuxhobby backup]$  split-b 4000k skype_backup. Tar . GZ skype_backup_20090626. tar . gz. –verbose
Creating file ' skype_backup_20090626. Tar . gz.aa '
creating file ' skype_backup_20090626. Tar . gz.ab '
creating file ' skype_backup_20090626. Tar . gz.ac '
creating file ' skype_backup_20090626. Tar . Gz.ad '
[marco.chan@linuxhobby backup]$ ls
skype_backup skype_backup_20090626. Tar . Gz.ac
skype_backup_20090626. Tar . Gz.aa skype_backup_20090626. tar . Gz.ad
skype_backup_20090626. Tar _20090626.gz.ab skype_backup. tar . GZ

-b Specifies the size of the partition, such as K,m.
–verbose output Split file information, optional.
Skype_backup. tar. gz partitioned file.
skype_backup_20090626. tar. gz. The separated file name (note "." After GZ), if not specified, the default is Xaa,xab,xac.

Now through tar, split, the Skype_backup directory files have been packaged and split into each of the largest 4M-size compression packs.
This is done step-by-step, if the pipe "|" is used, the tar, split is written as an execution statement:

Use pipe "|" Merge two directives:
[Marco.chan@linuxhobby backup]$ tar -czvp-f–skype_backup |split-b 4000k–skype_backup_20090626. Tar. gz. –verbose
[Marco.chan@linuxhobby backup]$ ls
Skype_backup
skype_backup_20090626. tar. Gz.aa
skype_backup_20090626. tar. Gz.ab
skype_backup_20090626. tar. gz.ac
skype_backup_20090626. tar. gz.ad

Notice that the two "-" in the instruction, if executed separately, does not use "-". Why there is this "--".

Mans Tar
-f,–file [hostname:]f
Use archive file or device F (default "-", meaning stdin/stdout). Note that "/dev/stdout" isn't equivalent to "-". The Using "/dev/stdout" explicitly can leads to corrupted archive, and especially when coupled with "-V".

How to extract the split file .
The file split a few packets, of course, to be able to merge the decompression, the merged files of course with Cat, cat is not only used to process the merged text files, can also be used to merge compressed files.

Cat Merge Split file:
[Marco.chan@linuxhobby backup]$ cat skype_backup_20090626. Tar. gz.a* >skype_backup_cat. tar. GZ

Merges the previously segmented compression packets into skype_backup_cat. tar. GZ, and then you can extract skype_backup_cat from the tar -zxvf. tar. GZ, through the pipe "|" Can be written as:

Use pipe "|" Merge two directives:
[Marco.chan@linuxhobby backup]$ cat skype_backup_20090626. Tar. gz.a* | tar -zxv

For more tar , split, cat instruction applications, it is recommended to pass the man query. Please specify the source: Wheat's not old pavilion  »  use tar and split to package split files This article address: http://www.uncle.ws/2009/ 06/ tar -split-cat/subscribe to blog address: http://www.uncle.ws/subscribe/

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.