In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you the Shell command file compression and decompression of gzip, zip case study, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
1.gzip:gzip Compression tool
The functional description of the gzip command:
The gzip command is used to compress files. Gzip is a widely used compression program that compresses files with the .gz extension after their names.
The syntax format of the gzip command:
Gzip [- acdfhlLnNrtvV19] [- S suffix] [name.] gzip [- acdfhlLnNqrtvV] [- S] [-] [--best/fast] [file.] Or gzip [- acdfhlLnNqrtvV] [- S] [-] [--best/fast] [directory]
Common parameters of the gzip command are described as follows:
There are many parameters for gzip. The following are the parameters and description of the gzip command:
Explanation of parameter options
-an or-- ascii uses ASCII text mode.
-c or-- stdout or-- to-stdout outputs the compressed file to a standard output device without changing the original file.
-d or-- decompress or-uncompress unpack the compressed file.
-f or-- force forcibly compress the file. Regardless of whether the file name or hard connection exists and whether the file is a symbolic link.
-h or-- help online help.
-l or-- list lists information about the compressed file.
-L or-- license displays version and copyright information.
When-n or-- no-name compresses a file, the original file name and timestamp are not saved.
When-N or-- name compresses the file, saves the original file name and timestamp.
-Q or-- quiet does not display a warning message.
-r or-- recursive recursive processing, processing all files and subdirectories under the specified directory together.
-S or-suffix changes the compressed suffix string.
-t or-- test tests whether the compressed file is correct.
-v or-- verbose shows the instruction execution process.
-V or-- version displays version information.
-Compression efficiency is a value between 1Mui 9 and the default value is "6". The higher the specified value, the higher the compression efficiency.
-- best this parameter has the same effect as specifying the "- 9" parameter.
-- fast this parameter has the same effect as specifying the "- 1" parameter.
Practical operation of gzip command
Example 1: compressed file
[root@m01 ~] # ls displays the current directory file a.c b.h d.cpp [root@m01 ~] # gzip * all files in the compressed directory [root@w3cschool.cc a] # [root@m01 ~] # ls shows the current directory file a.c.gz b.h.gz d.cpp.gz
Example 2: follow example 1 and list the detailed information
[root@m01] # gzip-dv * extract the file and list the details a.c.gz: 0. 0%-- replaced with a.cb.h.gz: 0. 0%-- replaced with b.hd.cpp.gz: 0. 0%-- replaced with d.cpp
Example 3: follow example 1 to display the information of the compressed file
[root@m01] # gzip-l * compressed uncompressed ratio uncompressed_name 24 0 0 0% a.c 24 0 0 0% b.h 26 0 0 0% d.cpp
2. Zip: compression tool
Functional description of the zip command
The zip command is used to compress files. Zip is a widely used compression program that compresses files to produce additional compressed files with the .zip extension.
Syntax format of the zip command
Zip [- aABcdDeEfFghjklLmoqrRSTuvVwXyzcompressed $] [--longoption...] [- b path] [- n suffixes] [- t date] [- tt date] zip [- AcdDfFghjJKlLmoqrSTuvVwXyz$] [- b] [- ll] [- n] [- t] [-] [compressed file] [file.] [- I] [- x]
Common parameters of the zip command are described as follows:
There are many parameters for zip. The following are the parameters and description of the zip command:
Explanation of parameter options
-An adjusts the executable automatic unzipping file.
-b specifies the directory where the files are temporarily stored.
-c comment each compressed file.
-d removes the specified file from the compressed file.
-D the directory name is not established in the compressed file.
-f the effect of this parameter is similar to that of specifying the "- u" parameter, but not only updates the existing file, but also adds some files to the compressed file if they do not already exist in the compressed file.
-F attempts to repair a corrupted compressed file.
-g append a compressed file to an existing compressed file instead of creating a new one.
-h online help.
-I only compress files that meet the criteria.
-j saves only the file name and its contents, but does not store any directory names.
-J deletes unnecessary data in front of the compressed file.
-k uses file names in MS-DOS-compatible format.
When compressing a file, replace LF characters with LF+CR characters.
-ll replaces LF+CR characters with LF characters when compressing the file.
-L displays copyright information.
-m after compressing the file and adding the compressed file, delete the original file, that is, move the file to the compressed file.
-n does not compress files with specific suffix strings.
-o set the change time of the compressed file to the same as the file with the latest change time in the compressed file.
-Q does not show the instruction execution process.
-r Recursive processing, processing all files and subdirectories under the specified directory together.
-S contains system and hidden files.
-t sets the date of the compressed file to the specified date.
-T check that each file in the backup file is correct.
-u replace the newer file into the compressed file.
-v displays instruction execution or version information.
-V saves the file properties of the VMS operating system.
-w if the version number is in the file name, this parameter is valid only under the VMS operating system.
-x excludes eligible files when compressing.
-X does not save additional file properties.
-y saves the symbolic link directly, not the file that the connection points to. This parameter is valid only in systems such as UNIX.
-z comment the compressed file.
-$saves the volume name of the disk where the first compressed file is located.
-Compression efficiency is a value between 1 and 9.
Practical operation of zip command
Example 1: package all files and folders in the / home/html/ directory to the html.zip in the current directory:
Zip-Q-r html.zip / home/html
Example 2: if we are in the / home/html directory, we can execute the following command:
Zip-Q-r html.zip *
Example 3: delete the file a.c from the compressed file cp.zip
Zip-dv cp.zip a.c
The above are all the contents of the Shell command file compression and decompression of gzip, zip case studies, thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.