linux zip and unzip commands

Reference address:

http://man.linuxde.net/zip

http://man.linuxde.net/unzip

zip command:

The zip command can be used to unzip or pack files. zip is a widely used compression program that compresses files to additionally produce compressed files with a ".zip" extension.

grammar

zip(options)(parameters)

Options

-A: Adjust executable automatic decompression files;
-b<working directory>: Specify the directory where files are temporarily stored;
-c: add a comment to each compressed file;
-d: delete the specified file from the compressed file;
-D: Do not create a directory name in the compressed file;
-f: The effect of this parameter is similar to specifying the "-u" parameter, but not only updates existing files, but if some files do not originally exist in the compressed file, using this parameter will add them to the compressed file together;
-F: Attempt to repair corrupted compressed files;
-g: Append the compressed file to the existing compressed file instead of creating a new compressed file;
-h: online help;
-i <template style>: only compress files that meet the conditions;
-j: save only the file name and its content, not any directory name;
-J: delete unnecessary data in front of the compressed file;
-k: use the file name in MS-DOS compatible format;
-l: When compressing files, replace LF characters with LF+CR characters;
-ll: When compressing files, replace LF+ cp characters with LF characters;
-L: Display copyright information;
-m: After compressing the file and adding it to the compressed file, delete the original file, that is, move the file to the compressed file;
-n <suffix string>: do not compress files with a specific suffix string;
-o: The file with the latest change time in the compressed file shall prevail, and the change time of the compressed file is set to be the same as the file;
-q: Do not display the instruction execution process;
-r: Recursive processing, processing all files and subdirectories in the specified directory together;
-S: include system and hidden files;
-t <date time>: Set 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: Display instruction execution process or display version information;
-V: Save the file attributes of the VMS operating system;
- w : If the version number is in the file name, this parameter is only valid under the VMS operating system;
-x <template style>: Exclude eligible files when compressing;
-X: do not save extra file attributes;
-y: directly save the symbolic link, not the file pointed to by the link, this parameter is only valid under systems such as UNIX;
-z: add a comment to the compressed file;
-$: Save the volume name of the disk where the first compressed file is located;
-<compression efficiency>: The compression efficiency is a value between 1 and 9.

parameter

  • zip archive: specify the zip archive to be created;
  • File List: Specify a list of files to compress.

example

Package all /home/Blinux/html/files and folders in this directory into html.zip in the current directory:

zip -q -r html.zip /home/Blinux/html

The above command operation is to compress the files and folders of absolute addresses. The following is a compressed relative path directory. For example, in the current directory of Bliux, the following operations can achieve the same effect as above:

zip -q -r html.zip html

For example, in my html directory now, the zip compression command I operate is:

zip -q -r html.zip *

unzip command:

The unzip command is used to decompress the ".zip" archive compressed by the zip command.

grammar

unzip(options)(parameters)

Options

-c: Display the decompressed result on the screen and convert the characters appropriately;
-f: update existing files;
-l: Display the files contained in the compressed file;
-p: Similar to the -c parameter, the decompressed result will be displayed on the screen, but no conversion will be performed;
-t: Check if the compressed file is correct;
-u: Similar to the -f parameter, but in addition to updating existing files, other files in the compressed file are also extracted into the directory;
-v: Display detailed information when executing;
-z: Display only the remark text of the compressed file;
-a: Perform the necessary character conversion on the text file;
-b: Do not perform character conversion on text files;
-C: file names in compressed files are case-sensitive;
-j: Do not process the original directory path in the compressed file;
-L: Change all file names in the compressed file to lowercase;
-M: Send the output result to the more program for processing;
-n: Do not overwrite the original file when decompressing;
-o: No need to ask the user first, the original file will be overwritten after unzip is executed;
-P <password>: use the password option of zip;
-q: do not display any information when executing;
-s: Convert whitespace characters in filenames to underscore characters;
-V: Keep the file version information of VMS;
-X: Save the original UID/GID of the file at the same time when decompressing;
-d <directory>: Specifies the directory where the file is to be stored after decompression;
-x <file>: specify which files in the .zip archive should not be processed;
-Z: unzip-Z is equivalent to executing the zipinfo command.

parameter

Archive: Specify the ".zip" archive to be decompressed.

example

Unzip the compressed file text.zip in the current directory.

unzip test.zip

Unzip the compressed file text.zip in the specified directory /tmp. If the same file already exists, ask the unzip command not to overwrite the original file.

unzip -n test.zip -d /tmp

View the compressed file directory, but do not extract it.

unzip -v test.zip

Unzip the compressed file test.zip in the specified directory /tmp. If the same file already exists, ask the unzip command to overwrite the original file.

unzip -o test.zip -d tmp/

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326070396&siteId=291194637