Linux gzip, gunzip, and linuxgzipgunzip

Source: Internet
Author: User
Tags uncompress

Linux gzip, gunzip, and linuxgzipgunzip
Introduction

Gzip is a linux built-in compressed file command. Its compression ratio is about 60%-70%, which is higher than that of zip. Use gzipzip to add the. GZ suffix after the file and delete the source file. Gunzip is the decompression command.

 

Gzip

1. do not specify the path

gzip filename
[root@master backup]# lltotal 4-rw-r--r--. 1 root root 1900 Sep 18 18:15 abc.sql[root@master backup]# gzip abc.sql [root@master backup]# lltotal 4-rw-r--r--. 1 root root 719 Sep 18 18:15 abc.sql.gz

2. Specify the path and keep the source file. Note that-c and output must not be omitted.

gzip -c filename >newfilename
[Root @ master backup] # gzip-c abc. SQL> abc. SQL .gz ### if the absolute path is not specified, the file [root @ master backup] # lltotal 8-rw-r -- r -- will be generated in the current directory --. 1 root 1900 Sep 18 18:15 abc. SQL-rw-r --. 1 root 719 Sep 18 18:33 abc. SQL .gz [root @ master backup] # gzip-c abc. SQL>/abc. SQL .gz ### specify the absolute path [root @ master backup] # ll/total 130-rw-r -- r --. 1 root 719 Sep 18 18:34 abc. SQL .gz

3. List compressed file information

gzip -l filename
[root@master backup]# gzip -l abc.sql.gz          compressed        uncompressed  ratio uncompressed_name                719                1900  63.9% abc.sql

The output content contains the file size, compression ratio, and file name before and after compression.

Related options:

-A or -- ascii: Use the ASCII text mode;-c: standard output: decompressed files, retain the source files. -D or -- decompress Or ---- uncompress: uncompress the compressed file;-f or -- force: forcibly compress the file. Ignore whether the file name or hard connection exists and whether the file is signed;-h or -- help: online help;-l or -- list: list information about the compressed file; -L or -- license: displays the version and copyright information.-n or -- no-name: When compressing a file, the original file name and time stamp are not saved.-N or -- name: when compressing a file, save the original file name and time stamp;-q or -- quiet: Do not display warning information;-r or -- recursive: recursive processing, process all files and subdirectories in the specified directory;-S or <compressed character string> or ---- suffix <compressed character string>: Change the compressed character string;-t or -- test: test whether the compressed file is correct;-v or -- verbose: displays the command execution process;-V or -- version: displays the version information;-<compression efficiency>: the compression efficiency is between 1 and ~ 9. The default value is "6". The larger the value, the higher the compression efficiency. -- best: the effect of this parameter is the same as that of the specified "-9" parameter; -- fast: the effect of this parameter is the same as that of the specified "-1" parameter.
Gunzip

The usage of gunzip is similar to that of zip.

1. decompress the file in the current directory. This method will delete the source file.

gunzip filename
gunzip abc.sql.gz

2. decompress the package to the specified directory and keep the source file-c

gunzip -c abc.sql.gz >abc.sql

3. view the file content. You can view the compressed file content when you do not specify the target file using the-c parameter.

gunzip -c abc.sql.gz 

Option:

-A or -- ascii: uses the ASCII text mode;-c or -- stdout or -- to-stdout: standard output of extracted file content, keep the source file;-f or-force: uncompress the compressed file by force, regardless of whether the file name or hard connection exists and whether the file is signed connection;-h or -- help: online help;-l or -- list: lists information about the compressed file.-L or -- license: displays the version and copyright information.-n or -- no-name: indicates the decompressed file, if the compressed file contains the original file name and time stamp, it will be ignored and not processed;-N or -- name: during decompression, if the compressed file contains the original file name and timestamp, it will be stored back to the unlocked file;-q or -- quiet: no warning information is displayed;-r or -- recursive: recursive processing: all files and subdirectories in the specified directory are processed together;-S or <compressed character string> or ---- suffix <compressed character string>: Change the compressed character string; -t or -- test: test whether the compressed file is correct;-v or -- verbose: displays the command execution process;-V or -- version: displays the version information;

 

Summary

 

 

 

 

Note:

Author: pursuer. chen

Blog: http://www.cnblogs.com/chenmh

All essays on this site are original. You are welcome to repost them. However, you must indicate the source of the article and clearly give the link at the beginning of the article.

Welcome to discussion

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.