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 files: [[email protected] backup] $ lsskype_backup [[email protected] backup] $ tar-czvp-f skype_backup.tar.gz skype_backup... Skype_backup/marco. chan. skype/chat512.dbbskype _ backup/marco. chan. skype/user4096.dbbskype _ backup/marco. chan. skype/chatmsg256.dbbskype _ backup/shared. xmlskype_backup/shared. lck [[email protected] backup] $ lsskype_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 file: [[email protected] backup] $ split-B 4000 k skype_backup.tar.gz skype_backup_20090626.tar.gz. -verbosecreating 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 '[[email protected] backup] $ lsskype_backup skype_backup_20090626.tar.gz.acskype_backup_20090626.tar.gz.aa login 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:
Use the pipeline "|" to merge two commands: [[email protected] backup] $ tar-czvp-f-skype_backup | split-B 4000 k-skype_backup_20090626.tar.gz. -verbose [[email protected] backup] $ protected
Note that the two "-" in the command are not required for separate execution "-". Why does "-" exist "-"?
Man tar-f,-file [HOSTNAME:] FUse 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.
Cat merge and split files: [[email protected] 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:
Use the pipeline "|" to merge two commands: [[email protected] 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 of this assignment: Maimai's old age & raquo; usage
TarAnd split package
Split filesAddress: http://www.uncle.ws/2009/06/
Tar-Split-cat/subscription blog address: http://www.uncle.ws/subscribe/
(For conversion) use tar and split to package and split files