This article is a mirror article of machine translation, please click here to jump to the original article.

View: 23775|Reply: 9

[linux] Detailed explanation of zip compression and unzip decompression commands in CentOS

[Copy link]
Posted on 5/16/2017 9:37:07 AM | | |
The following commands are operated in the /home directory
cd /home #进入/home directory
1. Compress the mydata directory under the /home directory into mydata.zip
zip -r mydata.zip mydata #压缩mydata目录
2. Extract the mydata.zip under the /home directory into the mydatabak directory
unzip mydata.zip -d mydatabak
3. Compress the abc folder and 123.txt under the /home directory into a abc123.zip
zip -r abc123.zip abc 123.txt
4. Unzip the wwwroot.zip under the /home directory directly into the /home directory
unzip wwwroot.zip
5. Unzip the abc12.zip, abc23.zip, and abc34.zip under the /home directory into the /home directory at the same time
unzip abc\*.zip
6. Check the content in the wwwroot.zip under the /home directory
unzip -v wwwroot.zip
7. Verify whether the wwwroot.zip under the /home directory is complete
unzip -t wwwroot.zip
8. Extract all the files in the wwwroot.zip under the /home directory to the first-level directory
unzip -j wwwroot.zip
System operation and maintenance Warm reminder: qihang01 original content copyright, please indicate the source and original link for reprinting
=====================================================
Main parameters:
-c: The result of the unzip
-l: Displays the files contained in the compressed file
-p: Similar to the -c parameter, the result of the decompression 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, it also unzips other files from the compressed file into a directory
-v: Displays detailed information when executed
-z: Displays only the comment text of the compressed file
-a: Make the necessary character conversion to the text file
-b: Do not characterize text files
-C: File names in compressed files are case-sensitive
-j: Does not handle the directory path originally 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 unzipping
-o: You don't need to ask the user first, unzip will overwrite the original file after execution
-P<密码>: Password option to use zip
-q: No information is displayed when executed
-s: Convert the blank characters in the file name to underscore characters
-V: Keep the file version information of the VMS
-X: The original UID/GID of the file is stored when unzipped




Previous:New sword background scanning tool
Next:Test post publishing editing features
Posted on 1/3/2018 2:16:29 PM |
When unzipping, sometimes you want to overwrite the original file, otherwise you need to set permissions, re-upload, etc. It's troublesome.

If you add -o parameters after the unzip command, you will no longer ask for it, and you will directly overwrite the original file and unzip it, saving a lot of trouble.

Command: unzip -o filename.zip
 Landlord| Posted on 1/23/2018 2:29:54 PM |
Linux, compress multiple files into a single file

If multiple files are compressed into a single package, you can use the following command:
zip test.zip  1.txt 2.txt 3.txt



 Landlord| Posted on 12/13/2021 11:25:43 AM |
zip compresses all the contents (folders) of the current folder, excludes the test directory, excludes the logs directory of all subfolders, excludes the temp file of all subfolders

 Landlord| Posted on 12/13/2021 11:27:17 AM |
Linux zip command explained in detail

-A: Adjust the executable auto-unzip file;
-b<工作目录>: Specify the directory where the files are temporarily stored;
-c: Annotate each compressed file;
-d: Delete the specified file from the compressed file;
-D: The directory name is not established in the compressed file;
-f: The effect of this parameter is similar to specifying the "-u" parameter, but it not only updates the existing files, but also adds some files to the compressed file if they do not exist in the compressed file.
-F: Try to repair the corrupted compressed file;
-g: Attach the file to the existing compressed file, instead of creating a new compressed file;
-h: online help;
-i<范本样式>: Compress only eligible files;
-j: Only the file name and its contents are saved, not any directory name.
-J: Deletes unnecessary data in front of the compressed file;
-k: File name using MS-DOS compatible format;
-l: When compressing the file, replace the LF character with the LF+CR character;
-ll: When compressing the file, replace the LF+cp character with the LF character;
-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<字尾字符串>: Does not compress files with specific suffix strings;
-o: The file with the latest change time in the compressed file shall prevail, and the change time of the compressed file shall be set to the same as the file.
-Q: The instruction execution process is not displayed;
-r: Recursive processing, which processes all files and subdirectories in the specified directory together;
-S: Contains system and hidden files;
-t<日期时间>: Set the date of the compressed file to the specified date;
-T: Check whether each file in the backup file is correct;
-u: Replace the newer file with the compressed file;
-v: Display the 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<范本样式>: Exclude eligible files when compressing;
-X: does not save additional file attributes;
-y: Save the symbolic connection directly, not the file to which the link points, this parameter is only valid on systems such as UNIX;
-z: Add comments to the compressed file;
-$: the name of the volume on the disk where the first compressed file is stored;
-<压缩效率>: The compression efficiency is a value between 1~9.
 Landlord| Posted on 12/13/2021 11:32:31 AM |
Linux uses Vim to view the contents of a zip package without decompression

Vim commands can also be used to view the contents of a ZIP archive without having to extract it. It works with archive files and folders. In addition to ZIP, it can also be used with other extensions such as tar.xz, tar.bz2, tar, tbz.

For example: vim test.zip
 Landlord| Posted on 3/3/2022 9:58:18 PM |
Install zip and unzip packages offline with the following command:



zip-3.0-11.el7.x86_64.rpm (259.92 KB, Number of downloads: 0, 售价: 5 粒MB) unzip-6.0-24.el7_9.x86_64.rpm (172.48 KB, Number of downloads: 0, 售价: 5 粒MB)
 Landlord| Posted on 1/1/2024 7:20:22 AM |
Linux uses tar to create archive files
https://www.itsvse.com/thread-10715-1-1.html
 Landlord| Posted on 7/14/2025 8:52:11 AM |
Windows uses tar to compress and package folders
https://www.itsvse.com/thread-10896-1-1.html
 Landlord| Posted on 12/4/2025 3:06:43 PM |
Linux compression zip, 7z extreme compression (minimum file)
https://www.itsvse.com/thread-11152-1-1.html
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com