Linux Base command (MB) gzip command

Source: Internet
Author: User
Tags file size gz file

Reducing file size has two obvious benefits, one is to reduce storage space, and the other is to transfer files over the network, you can reduce the transmission time. Gzip is a regular use of Linux in the file compression and decompression of the command, both convenient and useful. Gzip can be used not only to compress large, less-used files to conserve disk space, but also to form the more popular compressed file format in Linux operating systems, along with the tar command. According to statistics, the gzip command has a 60%~70% compression rate for text files.

1. Command format:

gzip[parameters [file or directory]

2. Command function:

Gzip is a widely used compression program, the file after it compressed, after its name will be more than ". gz" extension.

3. Command parameters:

-A or--ASCII uses ASCII text mode.

-C or--stdout or--to-stdout the compressed file output to the standard output device, not to alter the original file.

-D or--decompress or----uncompress unzip the compressed file.

-F or--force to forcibly compress the file. Ignores the existence of file names or hard connections and whether the file is a symbolic connection.

-H or--help online Help.

-L or--list lists information about compressed files.

-L or--license displays version and copyright information.

-N or--no-name compressed files, the original file name and time stamp are not saved.

-N or--name, save the original file name and time stamp when compressing the file.

-Q or--quiet does not display a warning message.

-R or--recursive recursively, all files and subdirectories under the specified directory are processed together.

-s< compressed Word tail string > or----suffix< compressed word tail string > Change compressed Word tail string.

-T or--test test that the compressed file is correct.

The-V or--verbose displays the instruction execution process.

-V or--version display version information.

-num adjusts the speed of the compression with the specified number num,-1 or--fast represents the fastest compression method (low compression ratio),-9 or--best represents the slowest compression method (high compression ratio). The default value for the system is 6.

4. Use instance:

Example 1: Compress each file in the Test6 directory into a. gz file

Command:

Gzip *

Output

 [root@localhost test6]# ll Total 604---xr--r--1 root mail 302108 11-30 08:39-Linklog.log ---xr--r--1 mail users 302108 11-30 08:39 log2012.log-rw-r--r--1 mail users 11-30 08:39 g-rw-r--r--1 root mail 0 11-30 08:39 log2014.log-rw-r--r--1 root mail 0 11-30 08:39 log2015.log-rw-r--r--1 root mail 0 11-30 08:39 log2016.log-rw-r--r--1 root mail 0 11
       
-30 08:39 Log2017.log [root@localhost test6]# gzip * [root@localhost test6]# ll Total 28 ---xr--r--1 root mail 1341 11-30 08:39 linklog.log.gz---xr--r--1 mail users 1341 11-30 08:39 LOG2012.L og.gz-rw-r--r--1 Mail users 11-30 08:39 log2013.log.gz-rw-r--r--1 root mail 32 11-30 08:    log2014.log.gz-rw-r--r--1 root Mail 11-30 08:39 log2015.log.gz-rw-r--r--1 root Mail 11-30 08:39 LOG2016.Log.gz-rw-r--r--1 root mail 11-30 08:39 log2017.log.gz [root@localhost test6]# 

Description

Example 2: Unzip each compressed file in Example 1 and list detailed information

Command:

GZIP-DV *

Output:

 [root@localhost test6]# ll Total---xr--r--1 root mail 1341 11-30 08:39-linklog.log.gz ---xr--r--1 mail users 1341 11-30 08:39 log2012.log.gz-rw-r--r--1 Mail users-11-30 08:39 Log2013.log  . gz-rw-r--r--1 root mail 11-30 08:39 log2014.log.gz-rw-r--r--1 root mail 32 11-30 08:39  log2015.log.gz-rw-r--r--1 root Mail 11-30 08:39 log2016.log.gz-rw-r--r--1 root Mail 32 11-30 08:39 log2017.log.gz [root@localhost test6]# GZIP-DV * linklog.log.gz:99.6%--Replaced WI Th linklog.log log2012.log.gz:99.6%--Replaced with Log2012.log log2013.log.gz:47.5%--replace D with Log2013.log log2014.log.gz:0.0%--Replaced with Log2014.log log2015.log.gz:0.0%--Rep  Laced with log2015.log log2016.log.gz:0.0%--Replaced with Log2016.log log2017.log.gz:0.0%-- Replaced with LOG2017.Log [root@localhost test6]# ll Total 604---xr--r--1 root mail 302108 11-30 08:39 linklog.log ---xr--r--1 mail users 302108 11-30 08:39 log2012.log-rw-r--r--1 mail users 11-30 Lo g2013.log-rw-r--r--1 root mail 0 11-30 08:39 log2014.log-rw-r--r--1 root mail 0 11-3       0 08:39 log2015.log-rw-r--r--1 root mail 0 11-30 08:39 log2016.log-rw-r--r--1 root Mail 0 11-30 08:39 log2017.log [root@localhost test6]# 

Description

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.