The compression formats commonly used in Linux include the following:. zip. gz. bz2. tar.gz tar.bz2. first of all, explain the top three.
compression in. zip Format: Zip Compress file names Original file name such as: Zip Abc.zip ABC
The suffix name must be written, although Linux does not care about the suffix, but we humans still want to see.
When you compress the directory, you need to add the option-R such as: Zip-r directory name source directory name
The decompression method is quite simple. Unzip "file or directory"
Note: Zip is common in win and Linux.
. gz format compression format: gzip "source file" Note: Compressed files in. gz format are compacted and the source files disappear.
Compressed directory: Gzip-r Directory Note: All sub-files in this directory are compressed, but the directory cannot be compressed.
. Gz method of Decompression
gzip-d "Compressed Files"
Gunzip "Compressed file" is equivalent to the two decompression methods.
Note: The unzip directory needs to be added-R
. BZ format compression format: bzip2 "source file" Note: Source files are not preserved
Bzip2-k "Compressed file" means: Keep source files after compression note: bZIP cannot compress the directory!
Unzip the. bz2 format:
bzip2-d "Compressed file" means: Uncompressed,-K reserved Compressed file
BUNZIP2 "Compressed file" means: Uncompressed,-K reserved Compressed file
Summing up: The above three kinds of compression decompression command said, in fact, these three kinds are not very commonly used, each have their own problems. zip is OK,. GZ can only compress sub-files in the directory, and BZIP2 can not compress the directory, which is very uncomfortable to use, the command type many do not say, there are various rules, Is there a simple way to solve this problem? We can imagine that we first put this file or directory in a package, and then compress the package, so that does not solve the order of the different attitude to the directory of the problem?
Package Command Tar
TAR-CVF "Package file name" "Source file"
Option:-C Package-V displays the packaging process-f Specifies the file name after packaging
This turns the file or directory into a package, and then compresses it with. zip,. bz2,. GZ, without worrying too much about the differences in the handling of these commands. Decompression is also used in the above method of decompression, just extract out or a. Tar package, you also need to unpack this package for normal use. Command:
TAR-XCF "Package file name" option-X means unpacking.
Summing up: This method just makes up for the previous three compression decompression command, you can use a unified format to manipulate compression and decompression, but! Is! This is still very uncomfortable ah! Clearly an order can be done, for Mao not to use two orders Ah!!!
Very good, the focus has come, foreshadowing so long, finally to the focus of today ~ ( ̄▽ ̄~) (~ ̄▽ ̄) ~
There are indeed commands to combine packaging and compression:
. tar.gz compression format
TAR-ZCVF "Compressed package name". tar.gz "source file" option:-Z compression to. tar.gz format, the other three options are the same as above.
. tar.gz Uncompressed Format
TAR-ZXVF "Compress package name". tar.gz option:-X Unzip
. TAR.BZ2 compression format
TAR-JCVF "Compressed package name". tar.bz2 "source file" option:-j compressed to. tar.bz2 format, the other three options are the same as above.
. TAR.BZ2 Uncompressed Format
TAR-JXVF "Compress package name". tar.bz2 Option:-X Unzip
Sum up: This is really really very simple, haha, in fact . tar.gz compression format and . TAR.BZ2 decompression format is the focus of today. Compression and decompression are pretty simple. d===== ( ̄▽ ̄*) b
learn PHP's small ant original blog http://my.oschina.net/woshixiaomayi/blog
Small Ant Learning Linux (6)--Compression and decompression commands in detail