Command name: zip
Function description: Compress files.
Syntax: zip [-AcdDfFghjJKlLmoqrSTuvVwXyz$][-b
Additional note: zip is a widely used compression program. After compression, it will additionally produce a compressed file with a ".zip" extension.
Parameters:
-A Adjust the executable automatic decompression file.
-b
-c Add comments to each compressed file.
-d Delete the specified file from the compressed file.
-D does not create a directory name in the compressed file.
-f The effect of this parameter is similar to that of specifying the "-u" parameter, but it 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.
-F Try to repair damaged compressed files.
-g Compress the file and append it to the existing compressed file instead of creating a new compressed file.
-h Online help.
-i Only compress files that meet the conditions.
-j only saves the file name and its content, without storing any directory name.
-J Delete unnecessary data in front of compressed files.
-k Use file names in MS-DOS compatible format.
-l When compressing files, replace LF characters with LF+CR characters.
-ll When compressing files, replace LF+CR 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
-o Based on the file with the latest change time in the compressed file, set the change time of the compressed file to be the same as the file.
-q does not display the instruction execution process.
-r Recursive processing, processing all files and subdirectories in the specified directory together.
-S Contains system and hidden files.
-t
-T Check whether each file in the backup file is correct.
-u Replace newer files into compressed files.
-v Displays the instruction execution process or displays version information.
-V Save the file attributes of the VMS operating system.
-w If there is a version number in the file name, this parameter is only valid under the VMS operating system.
-x Exclude files that meet the conditions when compressing.
-X does not save additional file attributes.
-y Directly saves the symbolic link instead of the file pointed to by the link. This parameter is only valid under systems such as UNIX.
-z Add comments to compressed files.
-$ Save the volume name of the disk where the first compressed file is located.
-
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
compression rate 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 files and folders in the current directory into test.zip file, -r means recursively compress all files in the subdirectory
[root@mysql test]# zip -r test.zip ./*
Packaging directory
[root@mysql test]# zip test2.zip test2/*
Example 3. Delete the test.MYI file
in the compressed file test1.zip [root@mysql test]# zip -d test1.zip test.MYI
Delete the files in the packaging file directory
[root@mysql test]# zip -d test2.zip test2/ln.log
deleting: tests/ln.log
Example 4. Add the test.MYI file to test1.zip in the compressed file
[root@mysql test]# zip -m test1.zip test.MYI
Example 5. Exclude a certain file when compressing files
[root@mysql test]# zip test3.zip tests/* -x tests/ln.log
Command name: unzip
Function description: Decompress zip file
Syntax: unzip [-cflptuvz][-agCjLMnoqsVX][-P
Additional note: unzip is a decompression program for .zip compressed files.
Parameters:
-c Display the decompression result on the screen and convert the characters appropriately.
-f Update existing files.
-l displays the files contained in the compressed file.
-p Similar to the -c parameter, the decompression result will be displayed on the screen, but no conversion will be performed.
-t Check whether the compressed file is correct. , but not decompression.
-u is similar to the -f parameter, but in addition to updating existing files, other files in the compressed file will also be decompressed into the directory.
-v displays detailed information when executing. Or view the compressed file directory without decompressing it.
-z Only displays the comment text of the compressed file.
-a Perform necessary character conversion on text files.
-b Do not perform character conversion on text files.
-C File names in compressed files are case-sensitive.
-j does 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 results to the more program for processing.
-n Do not overwrite the original files when decompressing.
-o No need to ask the user first, the original file will be overwritten after unzip is executed.
-P
-q does not display any information when executed.
-s Converts whitespace characters in file names to underscore characters.
-V Keep VMS file version information.
-X When decompressing, the original UID/GID of the file will be restored at the same time.
[.zip file] Specify the .zip compressed file.
[File] Specify which files in the .zip compressed file to be processed.
-d
-x
-Z unzip -Z is equivalent to executing the zipinfo command.
Example 1: Unzip the compressed file text.zip in the current directory.
[root@mysql test]# unzip test.zip
Example 2: Decompress the compressed file text.zip in the specified directory/tmp. If the same file already exists, the unzip command is required not to overwrite it. original document.
[root@mysql test]# unzip -n test.zip -d /tmp
Example 3: View the compressed file directory, but do not decompress it.
[root@mysql test]# unzip -v test.zip
Example 4: Decompress the compressed file test.zip in the specified directory tmp. If the same file already exists, the unzip command is required to overwrite it. original document.
[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