linux zip and unzip command details

  • 2020-05-13 04:24:20
  • OfStack

Recently, the linux zip/unzip commands have been sorted as follows:

Command name: zip

Function description: compress file.

Syntax: zip [-AcdDfFghjJKlLmoqrSTuvVwXyz $][-b < Work directory > ][-ll][-n < Trailing string > ][-t < Day period of time > ][- < Pressure reduction efficiency > ][compressed file][file...] [- i < Sample style > ][-x < Sample style > ]

Note: zip is a widely used compression program that will generate additional compression files with the ".zip "extension.

Parameters:

-A tunable to automatically extract executable files.

-b < Working directory > Refers to a directory where files are temporarily stored.

-c comments each compressed file.

-d deletes the specified file from the compressed file.

-D indentation file does not create directory name.

This parameter has the same effect as specifying the parameter "-u", but not only updates the existing files, if some files do not already exist in the compressed file, use this parameter to add 1 to the compressed file.

- F attempts to fix damaged compressed files.

-g compresses a file and appends it to an existing compressed file, rather than creating a new compressed file.

-h on line help.

-i < Sample style > Compress only qualified files.

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

-J deletes unnecessary data in front of the compressed file.

-k makes MS-DOS compatible with the lattice file name.

-l characters are replaced by LF+CR characters when the l file is compressed.

- when ll compresses a file, replace the LF+CR character with the LF character.

-L displays copyright information.

-m after the file is compressed and added to the compressed file, the original file is deleted, that is, the file is moved to the compressed file.

-n < Trailing string > Do not compress files that have a particular end-word string.

-o refers to the file with the latest change time in the compressed file, and sets the change time of the compressed file to the same as that of the file.

-q does not show instruction execution.

-r recursively processes all files and subdirectories 1 in the specified directory and processes them.

-S includes system and hidden files.

-t < Date/time > Sets the date of the compressed file to the specified date.

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

-u upgrade to a newer file to a compressed file.

-v displays the instruction execution process or version information.

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

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

-x < Sample style > Exclude eligible files when pressing.

-X does not save additional file properties.

-y direct saves a symbolic connection, not the file to which the connection points. This parameter is valid only on the system of the class UNIX.

-z comments the compressed file.

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

- < Compression efficiency > The compression efficiency is a number between 1 and 9.

example

Example 1. Compression 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 ratio 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. Compress all the files and folders in the current directory into test.zip, -r means to recursively compress all the files in the subdirectory


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

Package directory


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

Example 3. Delete the test.MYI file in the compressed test1.zip


[root@mysql test]# zip -d test1.zip test.MYI

Delete the files in the package file directory


 [root@mysql test]# zip -d test2.zip test2/ln.log

deleting: tests/ln.log

Example 4. Add test.MYI to test1.zip in a compressed file


[root@mysql test]# zip -m test1.zip test. MYI

Example 5. Exclude a file when compressing a file


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

Command name: unzip

Work can be explained: extract the zip document

Grammar: unzip [-cflptuvz][-agCjLMnoqsVX][-P < Secret code > ][.zip document][document][-d < directory > ][-x < file > [-] or unzip Z]

Note: unzip for the.zip compression file decompression program.

Parameters:

-c displays the unzipped results on the screen and converts the characters appropriately.

-f update an existing file.

-l shows the files contained in the compressed file.

The -p parameter is similar to the -c parameter in that it displays the unzipped results on the screen, but no conversion is performed.

-t checks the compressed file for correctness. But not decompress.

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

-v displays detailed information when executing. Or view the compressed file directory, but do not unzip it.

-z displays only the note text of the compressed file.

-a performs the necessary character conversion on the text file.

-b does not convert characters to text files.

- file names in C compressed files are case sensitive.

-j does not handle the original directory path of compressed files.

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

-M sends the output to more for sequential processing.

-n do not overwrite the original file when unzipping.

-o does not have to ask the user first; unzip overwrites the original file after execution.

-P < password > Make use of the zip password option.

-q does not display any information while executing.

-s converts white space characters in file names to baseline characters.

-V keeps the file version information of VMS.

-X unzips and saves the original UID/GID file at the same time.

[.zip file] specifies the.zip zip file.

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

-d < directory > Refers to the directory to be stored after the file is unzipped.

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

-Z unzip Z et al.

Example 1: unzip the compressed file text.zip in the current directory.


[root@mysql test]# unzip test.zip

Example 2: unzip the compressed file text.zip in the specified directory /tmp, and if the same file already exists, ask the unzip command not to overwrite the original file.


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

Example 3: view the compressed file directory, but do not unzip it.


[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
0

Example 4: unzip the compressed file test.zip under the specified directory tmp. If the same file already exists, ask the unzip command to overwrite the original file.


[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
1

use


[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
2

Unzip all zip files in the current directory


Related articles: