) Use tar and split to package and split files.

Source: Internet
Author: User

TarIt is a file packaging tool, and split is a file splitting tool. When sending attachments in an email, it may be necessary to compress and split the attachments due to the attachment size restriction and separate them into several emails. If you need to back up a lot of data, the size of a single file after packaging may exceed the size limit supported by the file system, you also need to split it into a suitable size file package. I just want to back up the Skype folder again today, so I will use this instance to explain it.TarAnd split commands, how to compress and split, and then decompress and restore the split files through cat merge, and package the files in the pipeline "|"Split filesProcess.

For example, my. Skype file is already as many as 35 mb. Now we need to compress and back up the file, and directly useTarPackaging:

use tar to compress the file:
[Marco. chan @ linuxholobby backup] $ ls
skype_backup
[Marco. chan @ linuxhober backup] $ tar -czvp-F skype_backup. tar . GZ skype_backup
the process of packaging, compression, and output is omitted...
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 @ linuxholobby backup] $ ls
skype_backup. tar . GZ skype_backup

Because the "-V" parameter is used, the compressed file information is output in the middle.
-C (create) is of course to create a packaging file.
-Z (gzip) calls gzip for compression. The recommended suffix is *.Tar. GZ; you can also use-J (Bzip2). The recommended suffix is *.Tar. Bz2.
-P (preserve-permissions) lowercase P, retain the original file attribute, that is, the rwx attribute.
-F (File) output target file "skype_backup.Tar. GZ "is the source file" skype_backup "to be processed. You can write-F in a row. However, to make it easier to remember and distinguish, the file is written separately.

The packaged skype_backup.Tar. GZ has a size of 15 MB, but my email attachments support 6 MB, so they must be separated.

Splite Split files :
[Marco. Chan @ linuxholobby backup] $Split-B 4000 K 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 @ linuxholobby 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 split size, such as K and M.
-Verbose outputSplit filesInformation. Optional.
Skype_backup.Tar. GZ split file.
Skype_backup_20090626.Tar. GZ. Split file name (note the "." After GZ). If not specified, the default value is xAA, XAB, and xac.

Now passTar, Split. The skype_backup directory file has been packaged and split into a compressed package of up to 4 MB.
The preceding steps are executed step by step. If MPs queue is used "|", SetTar, Split into an execution statement:

Merge two commands using MPs queue '|:
[Marco. Chan @ linuxholobby backup] $Tar-Czvp-F-skype_backup | split-B 4000 K-skype_backup_20090626.Tar. GZ.-verbose
[Marco. Chan @ linuxholobby 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

Note that the two "-" in the command are not required for separate execution "-". Why does "-" exist "-"?

ManTar
-F,-file [hostname:] F
Use archive file or device F (default "-", meaning stdin/stdout ). note that "/dev/stdout" is not equivalent to "-". using "/dev/stdout" explicitly can lead to initialize upted archive, especially when coupled with "-V ".

How to decompressSplit files?
Split the file into several packages. Of course, you must merge and decompress the files. The merged files use Cat. Cat is not only used to merge text files, but also to merge compressed files.

Merge and split cat files:
[Marco. Chan @ linuxholobby backup] $Cat skype_backup_20090626.Tar. GZ. A *> skype_backup_cat.Tar. GZ

Combine the split package into skype_backup_cat.Tar. GZ, and then you canTar-Zxvf to decompress skype_backup_cat.Tar. GZ, which can be written:

Merge two commands using MPs queue '|:
[Marco. Chan @ linuxholobby backup] $Cat skype_backup_20090626.Tar. GZ. A * |Tar-Zxv

For moreTar, Split, cat command application, it is recommended to use man query.

Please indicate the source for the transfer: The secret of maimai» use tar and split Packaging split file address: http://www.uncle.ws/2009/06/ tar -Split-CAT/subscribe 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.