Create and decompress tar, tar.gz and tar.bz2 files and compression ratios under Linux | Meditation Hut

Source: Internet
Author: User
Tags bz2 tmp file

just in the QQ group inside a man asked the file compression command, usually work with the decompression command, if you encounter compression is now checked (this is not a good habit), so to organize under the Linux create and unzip zip, tar, Tar.gz and tar.bz2 files are compared to their compression ratios to make it easier to remember when their brains have limited memory space and are infrequently used. It is now organized as follows:the current zip file extension is common under Linux: *. Z Compress Program Compressed files (the earliest use), compressed to replace the source files;
*.zip a Kua-platform File Packager for Linux, Windows, and Mac OS systems;
*.BZ2 bzip2 program compressed files;
*.gz gzip program compressed files;
*.tar tar program packaged files, and no compression;
*.tar.gz the TAR program to package the file, and through the GZIP program compression;
*.TAR.BZ2 the TAR program to package the files and pass the BZIP2 program compression. Tips: The so-called extension is only the general purpose of the Convention, is to make it easier to identify what type of compression, of course, you can package or compress the suffix name in any format, as long as you want.
A) *.zip format is the most common one, it has a boast operating system platform, can be used on Windows, Linux and Mac OS. You can compress files that need to be shared with Windows users in ZIP format. Compression and decompression. Zip format file: [[email protected] tmp]$ ZIP-R test.zip tmp
adding:test/(stored 0%)
Adding:test/data-file (deflated 24%)
ADDING:TEST/R (deflated 51%) The following is if you unzip a zip document: [[email protected] tmp]$ RM-RF test #为测试解压, first delete the TMP file in the current directory
[Email protected] tmp]$ Unzip Test.zip
Archive:test.zip
creating:test/
Inflating:test/data-file
INFLATING:TEST/RB) compressing and decompressing files in *.tar*,. tar.gz, *.tar.bz2 format and comparison:
Tar is a very extensive document packaging format used in Linux. Its advantage is that it consumes very little CPU and time to package files, he is just a packaging tool, not responsible for compression, compression is implemented by GZIP and bzip2.                So put *.tar*,. tar.gz, *.tar.bz2 Together for example: we want to package the test directory under directory/var/tmp to the current directory [[email protected] tmp]$ TAR-CVF Test.tar test # # # Only packaged, not compressed
[[email protected] tmp]$ TAR-ZCVF test.tar.gz Test # # # # # #
[[email protected] tmp]$ TAR-JCVF test.tar.bz2 Test # # # # # After packaging to bzip2 compression
[[email protected] tmp]$ ll test.tar* # # # Compare compressed file size
-rw-r--r--1 Lee mock 10240 01-18 17:05 Test.tar
-rw-r--r--1 Lee Mock 357 01-18 17:06 test.tar.bz2
-rw-r--r--1 Lee mock 327 01-18 17:05 test.tar.gz How to unpack the package: [[email protected] tmp]$ TAR-XVF Test.tar
[Email protected] tmp]$ TAR-XVF test.tar.gz
[Email protected] tmp]$ TAR-JXVF TEST.TAR.BZ2 the above test, each to remove the extracted test file after the decompression to the other directory, because if you do not define the directory path and the name is extracted by default to the current directory and the package name as the folder name. If you want to extract to a different directory (for example:/var/tmp/find) The following: [[email protected] tmp]$ tar-jxvf test.tar.bz2-c/var/tmp/find about tar.gz and tar.bz2 compression rates : *.tar.gz does not consume too much CPU when compressing, and can get a very good compression rate. will also be abbreviated to TGZ. *.TAR.BZ2 network good data that this compression format is the best compression rate, it is more than the previous way to occupy more CPU and time. But the above experiment showed that the size of the test.tar.gz was smaller than the test.tar.bz2 (does this mean that the *.tar.gz has a smaller compression rate?). At least this is the experiment.Attach the package of the quiz (click the file name to download) as follows:
2 files in the Test folder: Data-file and R
Test.tar test.tar.gz test.tar.bz2
This article from: Meditation hut Http://Leedd.Com
Original link: http://leedd.com/2010/01/linux-tar-tar-gz-tar-bz2/

Create and decompress tar, tar.gz and tar.bz2 files and compression ratios under Linux | Meditation Hut

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.