Zip command
Function description
Zip Program is a file compression tool is also a file archiving tool, files or directories can be compressed or decompressed, compressed format for zip. In Linux systems, Gzip is the main compression instruction, and BZIP2 is the second only. Linux users primarily use zip programs to swap files with Windows systems, rather than using them for compression or archival purposes. Use the following:
Zip [options] Compressed file name a list of documents that need to be compressed
Unzip [options] compress file names
Common parameters
Option description
Zip command
-R recursive compression to compress all files and subdirectories under the specified directory
-D Delete the specified file from within the compressed file
-I "file list" only compresses files in the file list
-X "File list" is compressed when the file specified in the Queued files list
-U update file to compressed file
-M compress the file into compressed file, delete the original file, that is, the horse file is moved to the compressed file
-F attempt to repair corrupted compressed file
-T checks that each file within the compressed file is correct
-# The compression level is a number between 1-9
Unzip command
-X "File list" unzip the file but does not include the file specified in the file list
-T test the compressed file for damage, and do not understand the pressure
-V View the details of the compressed file, including the file size, filename, and compression ratio contained in the compressed file, and
-N does not overwrite existing files when extracting
-O overwrites files that already exist and does not require user confirmation
-D directory name unzip the compressed file to the specified directory
Example
Compress all files and directories in the test directory
[app]# zip-9r Test.zip test/
Compression of all files and subdirectories in the test directory, except for *.gz files, the compressed files are saved in the current directory
[app]# ls-l Test
Total Dosage 216
-rw-r--r--. 1 root root 181 November 17:07 99.sh
-RW-------. 1 1127.www.qixoo.qixoo.com/root root 11595 November 17:07 messages
-rw-r--r--. 1 root root 1149 November 17:07 messages2.gz
-rw-r--r--. 1 root root 1202 November 17:07 messages.gz
-rw-r--r--. 1 root root 143538 November 17:07 shell.txt
-rw-r--r--. 1 root root 48218 November 17:07 shell.txt.bz2
[app]# zip-r test3.zip test-x "*.gz" #没有压缩 *.gz files
adding:test/(stored 0%)
adding:test/99.sh (deflated 30%)
Adding:qkxue.net/test/messages (deflated 90%)
Adding:test/shell.txt (deflated 62%)
ADDING:TEST/SHELL.TXT.BZ2 (deflated 0%)
Use the-d parameter to remove the Test/shell.txt file from the compressed package from the above Test3.zip
[app]# Zip test3.zip-d test/shell.txt
Deleting:test/shell.txt
Using the-u parameter, the modified/test/99.sh file is updated to update the changed information into the Test3.zip package
[app]# zip-u test3.zip/test/99.sh
updating:test/99.sh (deflated 30%)
If you have more files in the test directory, you can update them all to Test3.zip using the following method
[app]# Zip-ru test3.zip/test/
Extract the Test3.zip compressed files to the/tmp directory, and in the decompression process, such as if the same file will be overwritten directly, do not require user confirmation
[app]# unzip-o test3.zip-d/tmp/
[test]# pwd
/tmp/test
[test]# ls
99.sh Messages shell.txt.bz2
Linux command (+): Zip/unzip command-Package compression