Common compression commands on Linux Gzip,bzip2,zip/unzip
1. Gzip
Gzip-generated compressed file is *.gz
Format: gzip [-cdtv#] File
Main parameters:
-C: Output compressed data to the screen
-D: Decompression
-T: Used to verify if there are any errors in the compressed file
-V: Displays the compression ratio of the original file/compressed file case
-#: Compression level,-1 the fastest, but the compression ratio is the worst;-9 slowest, but the compression ratio is the best; preset is-6
Note: When using gzip to compress, the original file will be compressed into a. gz file name, and the source file will no longer exist.
Example
Compression:
Gzip Te
Compress the file te to te.gz and delete the file Te
Extract:
Gzip-d te.gz
Unzip the file te.gz to TE while deleting the file te.gz
------ZCAT Command
Format: Zcat file
The Zcat command can be used to read the contents of the. GZ compressed file
Zcat te.gz
Read the contents of the te.gz
2. bzip2
BZIP2 The resulting compressed file is *.bz2
Format: bzip2 [-cdkzv#] File
Main parameters:
-C: Output data from the compressed process to the screen
-D: Decompression
-K: Keep the source file without deleting the original file
-Z: Compressing
-V: Can display information such as the compression ratio of the original file/compressed file
-#: Compression level,-1 the fastest, but the compression ratio is the worst;-9 slowest, but the compression ratio is the best; preset is-6
Example
Compression:
Bzip2 te
Compress the file te to te.bz2 and delete the file Te
Bzip2-k te
to compress file Te to te.bz2, keep the file Te
Extract:
gzip-d te.bz2
Extract file te.bz2 to TE and delete files te.bz2
GZIP-KD te.bz2
Extract the file te.bz2 to TE while preserving the file te.bz2
------bzcat Command
Format: Bzcat file
The Bzcat command can be used to read the contents of the. bz2 compressed file
Bzcat te.bz2
Reads the contents of the TE.BZ2
3. Zip/unzip
Zip is the mainstream compression format under window, here is a brief introduction to
Format: Zip zipfile (. zip) file
compresses files to Zipfile.zip and preserves file files
Format: Unzip File.zip
Extract file File.zip, keep file File.zip
Example
Compress:
Zip te te
compress file te to Te.zip, keep file Te
Extract:
Unzip Te.zip
Extract the file Te.zip (the extracted file name can be renamed) while retaining the file Te.zip
Zip/unzip There are a bunch of other parameters, you can use the Man command to view