Compression and packaging

Source: Internet
Author: User

File compression principle: The file does not use space free (such as storing the number ' 1 ', only need a bit bit, but in order to meet the current operating system data access, the number ' 1 ' is stored as a byte, but in fact only the lowest one is useful, the other 7 bits are empty, This is a waste of 7 bits of space), there is a compression technique is the duplication of data to record statistics. (such as if the data in one of the files is "111 ..." 100 1, then the compression technique is recorded as "100 1")

Common ZIP file extensions:
*. z:comepress files compressed by the program;
*.zip:zip files compressed by the program;
*.gz:gzip files compressed by the program;
*.BZ2:BZIP2 files compressed by the program;
*.XZ:XZ files compressed by the program;
The *.tar:tar program is packaged with files that have not been compressed.
*.tar.gz:tar Packaging, gzip program compression
*.tar.bz2:tar Packaging, bzip2 program compression
*.tar.xz:tar Packaging, XZ compression

Gzip can be said to be the most widely used compression instructions.
gzip [-cdtv#] Document name
-C: The compressed data is output to the screen and can be processed through data flow redirection.
-D: the extracted parameters;
-T: You can verify the consistency of a compressed file to see if the file is error-free.
-V: Information such as the compression ratio of the source file/compressed file can be displayed.
-#: #为数字的意思, representing the compression level, 1 the fastest, but compression ratio,-9 slowest, but the best compression! The preset is-6.

When you compress using gzip, the original file is compressed into a. gz file, and the source file no longer exists in the preset state.
Zcat/zmore/zless: You can read compressed files that are compressed by plain text documents.
Zgrep: You can search for keywords without being able to press the file.

If GZIP is established to replace compress and provide a better compression ratio, then BZIP2 is to replace Gzip and provide a better compression ratio. The usage of bZIP is as follows:
bzip2 [-cdkzv#] Document name
-C: Output the data generated by the compression process to the screen!
-D: decompressed parameters
-K: Preserves source files without deleting original files
-Z: Compressed parameter (default value, can not add)
-V: can show the source file/compressed file compression ratio and other information
-#: #为数字, which represents the compression level.
Other available directives: Bzcat/bamore/bzless/bzgrep

Although Bzip2 already has a great compression ratio, some free software developers are not satisfied, so the XZ is later introduced in the compression ratio of the software, the use of gzip, bzip2 exactly the same.
XZ [-dtlkc#] Document name
-D: Decompression parameters
-T: Test the integrity of the file to see if there are any errors.
-L: Lists information about compressed files
-K: Keep source files
-C: Output data to the screen
-#: Digital, compression level

Tar: Packaging instructions
-C: Create a packaged file
-T: View the contents of a packaged file containing those document names, focusing on viewing the document name
-X: Unpacking, or extracting functionality
-Z: Compression/decompression via GZIP support: The document name is preferably *.tar.gz
-J: Compression/Decompression via BZIP2 support: The document name is preferably *.tar.bz2
-J: Compression/Decompression via XZ support: The document name is preferably *.TAR.XZ
-V: The name of the document being processed is displayed during the compression/decompression process.
-F FileName: Document name to be processed
-C Directory: This option is used in decompression, to extract in a specific directory, you can use this option.
-P: Preserve the original permissions and properties of the backed up data
-P: Retains the absolute path, that is, allows the backup data to contain the root directory exists meaning.
--exclude=file: Do not package FILE in the process of compression.

We will only use tar to package the files as Tarfile, if we also have compression support, we call tarball.

Tar CVF-etc | Tar xvf-one side of packaging, one side decompression, a bit like the meaning of CP.

Compression and packaging

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.