Zip unzip compression and decompression under Linux

Source: Internet
Author: User

NOTE: * Compress into limited. zip format files

Common decompression:

[Email protected] test]# Unzip-o test.zip-d tmp/

Unzip the compressed file Test.zip under the specified directory TMP , and require the unzip command to overwrite the original file if the same file exists.

Common compression:

[Email protected] test]# zip-r test.zip./*

All files and folders under the current directory are compressed into test.zip files, and-R indicates that all files in the subdirectory are compressed recursively.

The following commands are all operated under the/home directory
Cd/home #进入/home Directory
1. Compress the MyData directory below the/home directory to Mydata.zip
Zip-r Mydata.zip MyData #压缩mydata目录

2. Unzip the mydata.zip under the/home directory into the Mydatabak directory
Unzip mydata.zip-d Mydatabak

3, the home/home directory below the ABC folder and 123.txt compression becomes abc123.zip

Zip-r abc123.zip ABC 123.txt
4. Extract the Wwwroot.zip from the/home directory directly into the/home directory

Unzip Wwwroot.zip
5, the Home/home directory under the Abc12.zip, Abc23.zip, abc34.zip simultaneously extracted to the/home directory

Unzip Abc\*.zip
6. View the contents of the wwwroot.zip inside the/home directory

Unzip-v Wwwroot.zip
7. Verify that the wwwroot.zip under the/home directory is complete

Unzip-t Wwwroot.zip
8. Unzip all the files inside the/home directory under Wwwroot.zip to the first level directory

Unzip-j Wwwroot.zip
System operation and maintenance warm reminder: qihang01 original content copyright, reproduced please indicate the source and the original link
=====================================================
Main parameters
-C: Results that will be decompressed
-L: Displays files contained within the compressed file
-P: Similar to the-c parameter, the extracted results are displayed on the screen, but no conversions are performed
-T: Check that the compressed file is correct
-U: Similar to the-f parameter, but other files in the compressed file are extracted to the directory in addition to updating the existing file
-V: Show detailed information when performing Yes
-Z: Show only notes text for compressed files
-A: Necessary character conversions for text files
-B: Do not convert text files to characters
-C: File names in compressed files are case-sensitive
-j: does not handle the directory path of compressed files
-L: Change all file names in the compressed file to lowercase
-M: Send output to more program processing
-N: Do not overwrite the original file when decompressing
-O: Do not ask the user first, overwrite the original file after unzip execution
-p< Password: Use the zip password option
-Q: Do not display any information when executing
-S: Converts white space characters in file names to baseline characters
-V: Keep the file version information of the VMS
-X: Uid/gid The original file while decompressing

Function Description: Compress the file.

Syntax: Zip [-acddffghjjkllmoqrstuvvwxyz$][-b < working directory >][-ll][-n < tail string >][-t < date time >][-< compression efficiency >][compressed file [Documents ...] [-i < template style;] [-x < template style;]

Note: Zip is a widely used compression program that compresses files that have a ". zip" extension.

Parameters

-A adjusts the executable auto-unzip file.

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

-C adds a comment to each compressed file.

-d deletes the specified file from within the compressed file.

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

-F The effect of this parameter is similar to specifying the "-u" parameter, but not only updates the existing file, and if some files do not already exist in the compressed file, use this parameter to add it to the compressed file.

-F attempt to repair a corrupted compressed file.

-G compresses the file after it is appended to the existing compressed file, rather than creating a new compressed file.

-H online Help.

-i< template style > compress only files that match the criteria.

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

-J Delete unnecessary data before compressing the file.

-K uses the file name in MS-DOS compatible format.

-L When compressing a file, replace the LF character with the LF+CR character.

-ll the LF+CR character into the LF character when compressing the file.

-L displays copyright information.

-M compresses the file and joins the compressed file, deletes the original file, and then moves the file to the compressed file.

-n< string > does not compress a file with a specific trailing string.

-O to compress files that have the most recent change time in the file, set the change time for the compressed file to be the same as the file.

-Q does not show the instruction execution process.

-R recursively handles all files and subdirectories under the specified directory.

-S contains the system and hidden files.

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

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

-U replace the newer file into the compressed file.

-V Displays the instruction execution process or displays 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 files that match the criteria when compressing.

-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 only valid under systems such as UNIX.

-Z adds a comment to the compressed file.

-$ Save the volume book name of the disk where the first compressed file is located.

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

Example

Example 1. Compress test. MYI

[[email protected] test]# zip test1.zip test. MYI

Adding:test. MYI (deflated 42%)

[[email protected] test] #ll

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

The compression rate is 8

[[email protected] test]# zip test2.zip-8 test. MYI

Adding:test. MYI (deflated 42%)

[[email protected] test] #ll

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

Example 2. All files and folders under the current directory are compressed into test.zip files, and-r means all files in the recursive compressed sub-directory

[Email protected] test]# zip-r test.zip./*

Package Directory

[Email protected] test]# zip test2.zip test2/*

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

[Email protected] test]# zip-d test1.zip test. MYI

Remove files from the packaged files directory

[Email protected] 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

[Email protected] test]# zip-m test1.zip test. MYI

Example 5. Exclude a file when compressing a file

[[email protected] test]# zip test3.zip tests/*-x Tests/ln.log

command name : Unzip

function Description : Unzip the zip file

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

Additional note: Unzip is the unzip program for. zip compressed files.

Parameters

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

-F Updates an existing file.

-L Displays the files contained within the compressed file.

-P, similar to the-c parameter, displays the results of the decompression to the screen, but does not perform any conversions.

-T checks that the compressed file is correct. , but did not understand the pressure.

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

-V performs yes when the detailed information is displayed. or view the compressed files directory, but do not press.

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

-A necessary character conversion for the text file.

-B Do not convert the text file to character.

The file names in the-C compressed file are case sensitive.

-J does not handle directory paths that are contained in compressed files.

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

-M sends the output to the more program processing.

-N Do not overwrite the original file when extracting.

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

-p< password > password using zip option.

-Q does not display any information when executing.

-S converts white space characters in the file name to baseline characters.

-V retains the file version information for the VMS.

-X Unzip while the original uid/gid of the file is stored back.

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

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

-d< directory > Specifies the directory to be stored after the file has been decompressed.

-x< file > Specifies which files in the. zip archive are not processed.

-Z unzip-z equals execute zipinfo instruction.

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

[Email protected] test]# Unzip Test.zip

Example 2: Extract the compressed file Text.zip in the specified directory/TMP, if the same file exists, ask the unzip command not to overwrite the original file.

[Email protected] test]# unzip-n test.zip-d/tmp

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

[Email protected] test]# unzip-v test.zip

Zip unzip compression and decompression under Linux

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.