3. tar
CollationCompression benefits
1. Save space 2. save bandwidth
Solution
There are various types of compressed files. Why? The compression technology is updated, and the compression methods are not exactly the same. Different suffixes are easy to differentiate.
The earliest compress command-type compress is not very useful now. Later, a new generation of compression command gzip (GNU zip) was developed, and the bzip2 compression command with better compression ratio was developed.
Note: The two new commands mentioned above can only compress a single file, but cannot compress directories. Therefore, the software should be packaged.
However, packaging only combines all programs without praying for compression. Later, GUN planned to combine the packing box compression function to achieve a perfect combination.
The development process of this compression,
Detailed explanation
1. gzipFormat: gzip [-cd #] File Name
Parameters:
-C: output to the standard output (in this case, you must specify the output file) and save the original file.
-D: Extract
-#: Compression level. The larger the number, the more severe the compression, the longer the compression time. From 1 to 9. The default value is 6.
Instance:
Hello is a file, gzip hello is used, and the file is compressed, but the source file also disappears.
How can we see the content in the compressed file? Yes. Run the zcat command:
Uncompress: gzip-d hello.gz
Re-write the compressed file with the specified name? Redirect (the source file still exists ):
Compressed files in different ranges:
2.bzip2Format: bzip2 [-zdc #] File Name
Parameters:
-C: output to the standard output (in this case, you must specify the output file) and save the original file.
-Z: Compression
-D: Extract
-#: Compression level. The larger the number, the more severe the compression, the longer the compression time. From 1 to 9. The default value is 6.
Instance:
Compressed file hello: bzip2 hello (to hello.bz2)
Decompress hello.bz2: bzip2-d hello.bz2
Zip to a file named hel.bz2: bzip2-c hello> hel.bz2
Content of the hello.bz2 compressed file: bzcat hello.bz2
3. tarFormat: tar [-cxt zjvf] file and directory
Parameters:
-C: create Compression
-X: Extract
-T: view the compressed file content
Note: Only one of the three cxf parameters can be used at a time.
-Z: gzip compression during packaging
-J: Package and bzip2 Compression
-V: displays files during compression.
-F: use the file name
Note: After the-f parameter, the file name is directly added, that is, the end of f, and the parameter cannot be added.
-Cvf package only
Instance:
Compression directory del: the file name directory/file name after the tar parameter is compressed (you can see that the source file still exists)
Decompress: Enter the tar-xvf compressed file in the desired directory:
Compression to gz format:
Conclusion: tar.gz
- Compression: tar-zcvf a.tar.gz
- Decompress: tar-zxvf a.tar.gz