Concise Linux Command Line notes: gzip

Source: Internet
Author: User
Document directory
  • Parameters
  • Option
  • Example
  • Tips

Compress and decompress files

Gzip [Options] [File-list]

Gunzip [Options] [File-list]

Zcat [File-list]

 

The gzip program is used to compress files, the gunzip program is used to restore gzip compressed files, and the zcat program is used to display gzip compressed files.

After compression, the original file will be deleted, and the compressed file suffix is .gz.

 

Parameters

File-listList of path names of one or more files to be compressed or decompressed. IfFile-listIf the directory exists but no option-r existsGzip/gunzipReports error messages and ignores this directory.

Use the-r option,Gzip/gunzipRecursively compress/decompress files in the directory hierarchy

 

Option

-C writes the compressed or decompressed results to the standard output instead of the file

-D. decompress the gzip file. This option is used for gzip, which is equivalent to gunzip.

-F forcibly overwrite existing files during compression/Decompression

-L for each file to be compressed in file-list, the size, compression ratio, and file name before compression of the compressed and decompressed files are displayed.

-V to obtain other information

-N balances the compression speed and compression volume. N is from 1 ~ 9. Level 1st is the fastest compression, but the minimum compression volume; level 9th is the slowest compression speed, but the maximum compression volume.

The default value is 6. -- fast and -- best are equivalent to-1 and-9 respectively.

-Q: Do not display warning information

-R recursive compression/decompression of files in file-list

-T to verify the integrity of the compressed file. If the file is complete, no information is displayed.

-V: displays the file name, compressed file name, and the compression volume of each processed file.

 

Example gzip
siu@Darling ~/work $ lsa  b  c  dirsiu@Darling ~/work $ gzip asiu@Darling ~/work $ lsa.gz  b  c  dirsiu@Darling ~/work $ 

Compress the file and delete the original file.

 

Gzip-v
siu@Darling ~/work $ gzip -v bb:     26.4% -- replaced with b.gzsiu@Darling ~/work $ lsa.gz  b.gz  c  dir

Compress the file and display the compressed information.

 

Gunzip
siu@Darling ~/work $ gunzip a.gz siu@Darling ~/work $ lsa  b.gz  c  dir

Decompress the file, gunzip = gzip-d

 

Zcat
siu@Darling ~/work $ zcat b.gz Picture perfect memories scattered all around the floorReaching for the phone 'cause I can't fight it anymoreAnd I wonder if I ever cross your mindFor me it happens all the time

Show compressed file content without pressure

 

Gunzip-c
siu@Darling ~/work $ gunzip -c b.gz Picture perfect memories scattered all around the floorReaching for the phone 'cause I can't fight it anymoreAnd I wonder if I ever cross your mindFor me it happens all the time

Decompress the file to the standard output, that is, extract the content to the screen without modifying the file.

 

Gunzip-l
siu@Darling ~/work $ gunzip -l b.gz          compressed        uncompressed  ratio uncompressed_name                154                 182  26.4% bsiu@Darling ~/work $ lsa  b.gz  c  dir

Displays information about compression and decompression, but does not perform decompression.

 

Gzip-9-r
Siu @ Darling ~ /Work $ gzip-9-r dirsiu @ Darling ~ /Work $ lsa B .gz c dirsiu @ Darling ~ /Work $ ls-l dir total usage 12-rw-r -- r -- 1 siu 154 January 12 16:22 a.gz-rw-r -- 1 siu 154 January 12 16:22 B .gz-rw-r -- r -- 1 siu 154 January 12 16:22 c.gz

Recursively compress files in a directory in the way with the largest compression volume

 

Tips

Gzip compresses text files. We recommend that you use bzip2 to compress binary files or large files.

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.