One Linux command per day: gzip command

Source: Internet
Author: User

The compression command has two obvious advantages: one is to reduce the storage space, and the other is to reduce the transmission time when transmitting over the network.

According to statistics, the gzip command has a compression rate of 60%-70% for file files.

File presets with gzip compression the last extension is. gz.

In fact Gunzip is a hard link to gzip. Therefore, both compression and decompression can be done separately through the gzip instructions.

Grammar

gzip [options] [parameters]

Options

-A or--ascii: use ASCII text mode;
- C or--stdout or--to-stdout output the compressed file to the standard output device, not to change the original file -D or--decompress or----uncompress: Unpack the compressed file; F or--force: Forcibly compress the file. Ignores the existence of a file name or a hard connection and whether the file is a symbolic connection ;-h or--help: online Help;-L or--list: Lists information about compressed files;-L or--license: Display 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 the file, save the original file name and time stamp;-Q or--quiet: Do not display a warning message; R or--recursive: recursively handle all files and subdirectories under the specified directory "Recursive processing is only a single file compression processing, not all together into a package, except for the tar package" -S or < compress the tail string > or----suffix< compressed tail string >: Change the compressed word tail string;-t or--test: Test whether the compressed file is correct;-V or-- Verbose: show instruction execution process;-V or--version: Display version information; compression efficiencyis a value between 1~9, the default value is "6", specifying the larger value, The compression efficiency will be higher;--best: The effect of this parameter is the same as specifying the "-9" parameter;--fast: The effect of this parameter is the same as specifying the "1" parameter.

Parameters

File or directory

Precautions:

Only a single file compression operation, not a directory compression becomes a package.

The commonly used parameters are:-cdfrv< compression efficiency >

The default compressed file will delete the source file unless you specify the standard output to the (-C option) specified location.

Instance:

Example 1: Single file compression

gzip A.txt

Example 2: Compressing each individual file in the test directory

gzip *

Example 3: Unzip each compressed file in instance 2 and list the details

GZIP-DV *

Example 4: Detailed display of information for each compressed file in case of decompression

Gzip-l *

Example 5: Compress a tar backup file, at which time the zip file has the extension. tar.gz

gzip-r Log.tar

Example 6: Recursive compressed directory with detailed information displayed

GZIP-RV *

Example 8: Recursive extract Directory

Gzip-drv *

Example 9: Compressing the file a.txt to the/mnt/directory

gzip-c a.txt >/mnt/a.txt.gz

Note: the-C option can only manipulate individual files. If you are working with multiple files or folders, the standard output is a file of what format I do not know.

One Linux command per day: gzip command

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.