Linux zip/unzip Command Detailed _linux

Source: Internet
Author: User
Tags extract zip file

Recently cleaned up the Linux zip/unzip command, as follows:

Command name: Zip

Function Description: Compress file.

Syntax: Zip [-acddffghjjkllmoqrstuvvwxyz$][-b < working directory >][-ll][-n < word tail string >][-t < date time >][-< compression efficiency >][Compressed files [Document ...] [-i < template style] [-x < template style]

Supplemental Note: Zip is a widely used compression program, the file after it compression will produce a ". zip" extension of the compressed file.

Parameters

-A adjusts the executable automatic decompression file.

-b< working directory > Specifies the directory where files are temporarily stored.

-C adds a comment for each compressed file.

-d deletes the specified file from the compressed file.

The directory name is not established in the-D compressed file.

-F The effect of this parameter is similar to the specified "-u" parameter, but not only the existing file is updated, but if some files do not exist in the compressed file, this parameter will be added to the compressed file together.

-F attempts to repair a corrupted compressed file.

-G compresses the file and attaches it to the existing compressed file instead of creating a new compressed file.

-H online Help.

-i< template Style > compress only the eligible files.

-j only saves the file name and its contents, without any directory names.

-J Delete unnecessary data before compressing the file.

-K uses a file name in MS-DOS-compliant format.

-L replaces the LF character with the LF+CR character when compressing the file.

When-ll compressed files, replace the LF+CR characters with the LF character.

-L displays copyright information.

-M to compress the file and add the compressed file, delete the original file, that is, move the file to the compressed file.

-n< string > Do not compress files with a specific character end string.

-O Sets the time to change the compressed file to the same file as the file that has the latest change time in the compressed file.

-Q does not display the instruction execution process.

-R recursive processing of all files and subdirectories under the specified directory.

-S contains system and hidden files.

-t< Date Time > Set the date of the compressed file to the specified date.

-T checks that each file in the backup file is correct.

-U replaces the newer file with the compressed file.

-V Displays the instruction execution process or display version information.

-V Saves the file properties of the VMS operating system.

-W in the file name if the version number, this parameter is only valid under the VMS operating system.

-x< template style > exclude eligible files when compacting.

-X does not save additional file attributes.

-Y saves the symbolic connection directly, not the file that the connection points to, and this parameter is valid only for systems such as UNIX.

-Z Adds a comment for the compressed file.

-$ the volume name of the disk on which the first compressed file is stored.

-< compression Efficiency > Compression efficiency is a value between 1-9.

Example

Example 1. Compress test. Myi

[root@mysql test]# zip test1.zip test. Myi

adding:test. Myi (deflated 42%)

[root@mysql test] #ll

-rw-r--r--1 root  root  1033755 09-24 10:03 test1.zip

The compression rate is 8.

[root@mysql test]# zip test2.zip-8 test. Myi

adding:test. Myi (deflated 42%)

[root@mysql test] #ll

-rw-r--r--1 root  root  1033451 09-24 10:03 test2.zip

Example 2. Compresses all files and folders in the current directory into Test.zip files,-r means all files in a recursive compressed subdirectory

[Root@mysql test]# zip-r test.zip./*

Packaging Catalog

[Root@mysql test]# zip test2.zip test2/*

Example 3. Delete test.myi files in compressed file Test1.zip

[Root@mysql test]# zip-d test1.zip test. Myi

Delete files in the packaged files directory

 [Root@mysql test]# zip-d test2.zip test2/ln.log deleting:tests/ln.log


Example 4. Add the test. myi file to the Test1.zip in the compressed file

[Root@mysql test]# zip-m test1.zip test. Myi

Example 5. Exclude a file when compressing files

[Root@mysql test]# Zip test3.zip tests/*-x Tests/ln.log

Command name: Unzip

Function Description: Extract zip file

Syntax: Unzip [-cflptuvz][-agcjlmnoqsvx][-p < password >][.zip file] [file][-d < directory >][-x < file] or unzip [-z]

Supplemental Note: Unzip is the decompression program for the. zip compressed file.

Parameters

-C Displays the uncompressed results to the screen and converts the characters appropriately.

-F to update existing files.

-L Displays the files contained within the compressed file.

-P, similar to the-c parameter, displays the uncompressed results to the screen, but does not perform any transformations.

-T check that the compressed file is correct. , but puzzled pressure.

-U is similar to the-f parameter, but in addition to updating an existing file, the other files in the compressed file are uncompressed to the directory.

-V displays detailed information when it is executed. or view the compressed file directory, but do not understand the pressure.

-Z Displays only the memo text for the compressed file.

-A makes the necessary character conversions to the text file.

-B Do not convert text files to characters.

The file name in the-C compressed file is case-sensitive.

-J does not handle the directory path in the compressed file.

-L Change all file names in the compressed file to lowercase.

-M sends output to more program processing.

-N uncompressed does not overwrite the original file.

-O does not need to ask the user first, overwriting the original file after unzip execution.

-p< Password > Use zip password option.

-Q does not display any information at execution time.

-S converts the whitespace character in the file name to the bottom line character.

-V preserves file version information for VMS.

-X to save the original uid/gid of the file while decompressing.

[. zip file] Specifies a. zip compressed file.

[file] Specifies which files in the. zip compressed file to process.

-d< directory > Specifies the directory to store after the file is uncompressed.

-x< file > Specify which files in the. zip compressed file should not be processed.

-Z unzip-z is equal to executing zipinfo directives.

Example 1: Unzip the compressed file Text.zip under the current directory.

[Root@mysql test]# Unzip Test.zip

Example 2: Text.zip the compressed file in the specified directory/TMP, and if the same file exists, requires that the unzip command not overwrite the original file.

 [Root@mysql test]# unzip-n test.zip-d/tmp

Example 3: View the compressed file directory, but do not understand the pressure.

 [Root@mysql test]# unzip-v Test.zip

Example 4: Extract the Compressed file (Test.zip) under the specified directory TMP, and if the same file exists, require the unzip command to overwrite the original file.

[Root@mysql test]# unzip-o test.zip-d tmp/

Use

Unzip "*.zip"

ls *.zip | xargs-n1 unzip

Unzip all zip files in the current directory

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Related Article

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.