Linux Study Notes-compression and decompression commands
. Zip format compression:
Zip compressed file name source file # compressed file zip-r compressed file name source directory # compressed directory
Decompress in. zip format:
Unzip compressed file unzipped. ZIP Format File
Note:
1) The zip command can compress files or compress directories.
2). The zip compression format is common in Linux and Windows systems.
. Gz format compression:
Gzip source file # compressed file, the source file will disappear gzip-c source File> compressed file name # compressed file, the source file will not disappear gzip-r directory # All the sub-files under the compressed directory, but the directory cannot be compressed
Decompress in. gz format:
Gzip-d compressed file uncompressed. GZ file gunzip compressed file uncompressed. GZ file gunzip-r directory uncompressed all .gz files under the Directory
Note:
1) the gzip command compresses all the sub-files in the directory.
. Bz2 format compression:
Bzip2 source file # compressed file, the source file will disappear bzip2-k source file # compressed file, the source file will not disappear
. Bz2 format decompression:
Bzip2-d compressed file # decompress the file, the compressed file will disappear, plus-k will not disappear bunzip2 compressed file # decompress the file, the compressed file will disappear, plus-k will not disappear
Note:
1) The bzip2 command cannot compress directories.
. Tar.gzand .tar.bz2 format compression:
Tar-zcvf: compressed file name source file or source directory; compressed file or directory: .tar.gz format tar-jcvf: compressed file name source file or source directory; compressed file or directory: .tar.bz2 format
Decompress in .tar.gzand .tar.bz2 format:
Tar-zxvf compressed file unzip uncompress .tar.gz Format File tar-jxvf compressed file unzip uncompress .tar.bz2 Format File
Note:The options behind the tar command are as follows.
"Tar-c" packaging "tar-v" shows the packaging process "tar-f" specifies the packaged file name "tar-x" for unpackaging, opposite to-c, "tar-z" is compressed into .tar.gz format, "tar-j" is compressed into .tar.bz2 format.
Below are several common examples of compression and decompression.
Common examples:
1) archive the log.txt file in. ZIP format, save the compressed file to the test directory, and decompress the compressed file under the test directory.
2) decompress the shdirectory into the. ZIP format, save the compressed file to the test directory, and decompress the compressed file under the test directory.
3) compress the log.txt file and shdirectory into the all.tar.gz file, and decompress the contents in the compressed file to the test directory.