Under Linux file system compression and packaging commands
Commonly used to expand the compressed file name
* .Z
* .zip
* .gz
* .bz2
* .xz
* .tar
* .tar.gz
* .tar.bz2
* .tar.xz
Compression command
gzip, cat / more / Less / grep
- Description: Replace the early compress command provides better compression ratio, the most widely used compression command, the establishment of a compressed file is * .gz
gzip [-cdtv#] 文件名
zcat 文件名.gz
- Parameter Description:
- -c: the compressed data output to the screen, the data stream may be processed by the redirection
- -d: Unzip the parameters
- -t: Check the consistency of the compressed file, see the file for errors
- -v: display the original document / file compression compression ratio
- - #: compression level [1-9], by default
6
- 1: The fastest, the worst compression ratio
- ...
- 9: slowest, the best compression ratio
- zcat / zmore / zless may correspond to a cat / more / less reads the compressed file is a plain text file compressed
bzip2, bzcat/bzmore/bzless/bzgrep
- Description: Replace gzip, suffix .bz2, usage almost in line with gzip.
bzip2 [-cdkzv#] 文件名
bzcat 文件名.gz
- Parameter Description:
- -c: the compressed data output to the screen, the data stream may be processed by the redirection
- -d: Unzip the parameters
- -k: keep the original files will not delete the original file
- -z: compression parameter (the default value, you can not add)
- -v: display the original document / file compression compression ratio
- - #: compression level [1-9], by default
6
- 1: The fastest, the worst compression ratio
- 9: slowest, the best compression ratio
具体范例
# 压缩并将信息显示
bzip2 -v services*
# 读出上例文件内容
bzcat services.bz2
# 解压缩
bzip2 -d services.bz2
# 将上例中解开的services采用最佳压缩比压缩,并保留原本文件
bzip2 -9 -c services > services.bz2
Note here -c ... > ...
's usage: original content to be output to the screen turn into File -> Specific seen in bash
xz, xzcat/xzmore/xzless/xzgrep
- Description: software higher compression ratio, the use of two substantially identical with the above-described
- Parameter Description:
- -c: the compressed data output to the screen, the data stream may be processed by the redirection
- -d: Unzip the parameters
- -t: Check the consistency of the compressed file, see the file for errors
- -l: List information about file compression
- -k: keep the original files will not delete the original file
- - #: compression level [1-9], by default
6
- 1: The fastest, the worst compression ratio
- 9: slowest, the best compression ratio
Compare the running time of a few commands
time [gzip|bzip2|xz] -c wget-log > log.[gz|bz2|xz]
Package command
takes
- Description: a plurality of files or directories to package a large file command
- Description of common parameters
- -c [can be used with -v] established packed files
- -t [can be used with -v] to view the content
- -x [can be used with -v] decompression
- -v show up in the file name processing
- -z gzip compression by supporting / decompression, the best file extension is .tar.gz
- -j bzip2 compressed by supporting / decompression, file name suffix is the best .tar.bz2
- -J by xz ~~, file suffix .tar.xz
- -f file name to be processed immediately put together a single write may not forget []
- -C compression specific directory Solutions
- -p [can be used with -c] keep a backup of the original data attributes and privileges, commonly used for backup
- -P retained absolute path, which allows the root directory contains backup data exists
- --exclude = FILE during compression, will not pack FILE
- To note:
-z
,-j
,-J
not with the use!
- Commonly packaged with
- Packing and compression:
tar [-z|-j|-J] [cv] [-f 待建立的新文件名] filename
- View File Name:
tar [-z|-j|-J] [tv] [-f 既有的tar文件名]
- unzip:
tar [-z|-j|-J] [xv] [-f 既有的tar文件名] [-C目录]
- Packing and compression: