One linux Command (32) every day: gzip command

Source: Internet
Author: User
Tags gz file touch command uncompress

One linux Command every day (32): gzip command link: One linux Command every day (1): ls command http://www.bkjia.com/ OS /210210/163049.html#linuxlinuxcommand every day (2): cd command serial (3 ): pwd command Export (4): mkdir command http://www.bkjia.com/ OS /201210/1620.3.html#a linuxcommand every day (5): rm command Export (6): rmdir command http://www.bkjia.com/ OS /201210/164017. Html; one linux Command every day (7): mv command running (8): cp command http://www.bkjia.com/ OS /201210/163164.html#a linuxcommand every day (9): touch command running (10): cat command running (11 ): nl command http://www.bkjia.com/ OS /201211/165990.htmla linuxcommand every day (12): more command http://www.bkjia.com/ OS /201211/165994.htmllinuxcommand every day (13): Less command restart (14): head command http://www.bkjia.com/ OS /201211/166191.htmllinuxcommand every day (15): tail command restart (16): which command restart (17): whereis command restart (18 ): locate command http://www.bkjia.com/ OS /201211/168895.htmla linuxcommand every day (19): find command overview h Ttp: // timeout (20): exechttp of the find command: // www.bkjia.com/ OS /201211/168901.htmllinuxcommand every day (21): xargshttp of the find command: // timeout (22 ): detailed description of the parameters of the find command: http://www.bkjia.com/ OS /201211/168912.htmla linuxcommand every day (23): Linux directory structure (24): Linux file type and extension (2 5): linux File Attribute explanation example (26): Use SecureCRT to upload and download files. Example (27): linux chmod command example (28): tar command http://www.bkjia.com/ OS /201212/172.161.html A linuxcommand every day (29 ): chgrp command http://www.bkjia.com/ OS /201212/172983.htmla linuxcommand every day (30): chown command http://www.bkjia.com/ OS /201212/173239.htmlone per day Linux Command (31):/etc/group file DETAILS http://www.bkjia.com/ OS /201212/174429.html reduce file size has two obvious advantages, one is to reduce the storage space, the other is through the network to transfer files, this reduces the transmission time. Gzip is a frequently used command in Linux to compress and decompress files, which is convenient and easy to use. Gzip can be used not only to compress large and rarely used files to save disk space, but also to form popular compressed file formats in the Linux operating system together with the tar command. According to statistics, the gzip command has 60% ~ 70% compression rate. Www.2cto.com 1. command Format: gzip [parameter] [file or directory] 2. command function: gzip is a widely used compression program. After a file is compressed, its name will be added ". gz "extension. 3. Command Parameters:-a or -- ascii uses the ASCII text mode. -C or -- stdout or -- to-stdout outputs the compressed file to the standard output device, without changing the original file. -D or -- decompress Or ---- uncompress To uncompress the compressed file. -F or -- force forcibly compresses 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 lists information about compressed files. -L or -- license displays version and copyright information. -N or -- no-name: the original file name and time stamp are not saved. -N or -- name: the original file name and time stamp are saved when the file is compressed. -Q or -- quiet does not display warning information. -R or -- recursive processing: all files and subdirectories under the specified directory are processed together. -S <compression character string> or ---- suffix <compression character string> to change the compression character string. -T or -- test to test whether the compressed file is correct. -V or -- verbose displays the command execution process. -V or -- version displays version information. -Num uses the specified numeric num to adjust the compression speed.-1 or -- fast indicates the fastest compression method (low compression ratio), and-9 or -- best indicates the slowest compression method (high compression ratio ). The default value is 6. 4. example: www.2cto.com instance 1: compress each file in the test6directory into A. gz file command: gzip * output: [root @ localhost test6] # ll total 604 --- xr -- r -- 1 root mail 302108 11-30 linklog. log --- xr -- r -- 1 mail users 302108 11-30 log2012.log-rw-r -- 1 mail users 61 11-30 08:39 log2013.log-rw-r -- 1 root mail 0 11-30 08:39 log2014.log-rw-r -- 1 root mail 0 11-30 08:39 log2015.log-rw-r -- 1 root mail 0 11-30 08:39 log2016.log- rw-r -- r -- 1 root mail 0 11-30 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.log.gz-rw-r -- 1 mail users 70 11-30 08:39 log2013.log.gz-rw-r -- 1 root mail 32 11-30 08:39 log2014.log.gz-rw-r -- 1 root mail 32 11-30 08:39 log2015.log.gz-rw-r -- 1 root mail 32 11-30 0 8: 39 log2016.log.gz-rw-r -- 1 root mail 32 11-30 08:39 log2017.log.gz [root @ localhost test6] # Note: instance 2: extract each compressed file in Example 1, command: gzip-dv * output: [root @ localhost test6] # ll total 28 --- xr -- r -- 1 root mail 1341 11-30 linklog.log.gz --- xr -- r -- 1 mail users 1341 11-30 log2012.log.gz-rw -r -- 1 mail users 70 11-30 08:39 log2013.log.gz-rw-r -- 1 root mail 32 11-30 08:39 log2014.log.gz-rw-r -- 1 roo T mail 32 11-30 08:39 log2015.log.gz-rw-r -- 1 root mail 32 11-30 08:39 log2016.log.gz-rw-r -- 1 root mail 32 11-30 08:39 log2017.log.gz [root @ localhost test6] # gzip-dv * linklog.log.gz: 99.6% -- replaced with login: 99.6% -- replaced with log2012.log2013.log.gz: 47.5% -- replaced with log2013.log2014.log.gz: 0.0% -- replaced with log2014.log2015.log.gz: 0.0% -- rep Laced with login: 0.0% -- replaced with log2016.log2017.log.gz: 0.0% -- replaced with log2017.log [root @ localhost test6] # ll total 604 --- xr -- r -- 1 root mail 302108 11-30 linklog. log --- xr -- r -- 1 mail users 302108 11-30 log2012.log-rw-r -- 1 mail users 61 11-30 08:39 log2013.log-rw-r -- 1 root mail 0 11-30 08:39 log2014.log-rw-r -- 1 root mail 0 11-30 08:39 log201 5. log-rw-r -- 1 root mail 0 11-30 08:39 log2016.log-rw-r -- 1 root mail 0 11-30 08:39 log2017.log [root @ localhost test6] # note: example 3: details the information of each compressed file in Example 1. The command gzip-l * output is not extracted: [root @ localhost test6] # gzip-l * compressed uncompressed ratio uncompressed_name 1341 302108 linklog. log 1341 302108 99.6% log2012.log 70 61 47.5% log2013.log 32 0 0.0% log2014.log 32 0 0.0% log2015.log 32 0 0.0% log2016.log 32 0 0.0% log2017.log 2880 604277 99.5% (totals) Description: instance 4: compress a Tartar file. The extension name of the compressed file is .tar.gz. Command: gzip-r log.tar output: [root @ localhost test] # ls-al log.tar-rw-r -- 1 root 307200 11-29 17:54 log.tar [root @ localhost test] # gzip-r log.tar [root @ localhost test] # ls-al log.tar.gz-rw-r -- 1 root 1421 11-29 log.tar.gz description: example 5: recursive compression directory command: gzip-rv test6 output: [root @ localhost test6] # ll total 604 --- xr -- r -- 1 Root mail 302108 11-30 linklog. log --- xr -- r -- 1 mail users 302108 11-30 log2012.log-rw-r -- 1 mail users 61 11-30 08:39 log2013.log-rw-r -- 1 root mail 0 11-30 08:39 log2014.log-rw-r -- 1 root mail 0 11-30 08:39 log2015.log-rw-r -- 1 root mail 0 11-30 08:39 log2016.log- rw-r -- 1 root mail 0 11-30 08:39 log2017.log [root @ localhost test6] # cd .. [root @ localhost test] # gzip-rv tes T6test6/log2014.log: 0.0% -- replaced with test6/log2014.log.gz test6/linklog. log: 99.6% -- replaced with test6/linklog.log.gz test6/log2015.log: 0.0% -- replaced with test6/log2015.log.gz test6/log2013.log: 47.5% -- replaced with test6/log2013.log.gz test6/log2012.log: 99.6% -- replaced with test6/log2012.log.gz test6/log2017.log: 0.0% -- replaced with test6/log2017.log.gz test6/log2016.log: 0.0% -- re Placed with test6/log2016.log.gz [root @ localhost test] # cd test6 [root @ localhost test6] # ll total 28 --- xr -- r -- 1 root mail 1341 11-30 linklog.log.gz --- xr -- r -- 1 mail users 1341 11-30 log2012.log.gz-rw-r -- 1 mail users 70 11-30 08:39 log2013.log.gz-rw-r -- 1 root mail 32 11 -30 08:39 log2014.log.gz-rw-r -- 1 root mail 32 11-30 08:39 log2015.log.gz-rw-r -- 1 root mail 32 11-30 08:39 lo G2016.log.gz-rw-r -- 1 root mail 32 11-30 08:39 log2017.log.gz note: in this way, all files under test are changed *. gz, the directory still exists, but the files in the directory are changed *. gz. this is compression, which is different from packaging. Because it is a directory operation, you need to add the-r option, so that you can also perform recursion on the subdirectory. Example 6: recursively decompress the directory command: gzip-dr test6 output: [root @ localhost test6] # ll total 28 --- xr -- r -- 1 root mail 1341 11-30 linklog.log.gz --- xr -- r -- 1 mail users 1341 11-30 log2012.log.gz-rw -r -- 1 mail users 70 11-30 08:39 log2013.log.gz-rw-r -- 1 root mail 32 11-30 08:39 log2014.log.gz-rw-r -- 1 root mail 32 11-30 08:39 log2015.log.gz-rw-r -- 1 root mail 32 11-30 08:39 log2016.log.gz-rw-r -- 1 root mail 32 11-30 08:39 log2017.log.gz [root @ localhost test6] # cd .. [root @ localhost test] # gzip-dr test6 [root @ localhost test] # cd test6 [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 log2012.log-rw-r -- 1 mail users 61 11-30 08:39 log2013.log-rw-r -- 1 root mail 0 11-30 08:39 log2014.log-rw-r -- 1 root mail 0 11-30 08:39 log2015.log-rw-r -- 1 root mail 0 11-30 08:39 log2016.log- rw-r -- 1 root mail 0 11-30 08:39 log2017.log [root @ localhost test6] #

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.