Original URL: http://blog.csdn.net/Gildor/article/details/3358127
Now we all use WinRAR, do not know how many friends have heard of 7zip. 7zip is an open-source compression software, very small, provides the same functionality and WinRAR, but supports almost one more format than the latter. Based on my experience, the compression speed and compression ratio of the 7z compression format is also ahead of WinRAR (WinRAR also recognizes the 7z format, so you don't have to worry about compatibility issues). Another important point is that 7z is fully open source, including compression algorithms, and it is also easy to use the libraries it provides to integrate compression functionality into its own programs.
This time continue to study the command line usage of common tools. 7zip Core program is 7z.exe, command line format: 7z <command> [<switches> ...] <archive_name> [<file_names> ...] [< @listfiles ...;].
command is the operation instruction, as follows:
A add to the compressed file
B benchmark test, test 7z current performance
D Remove from compressed file
E is uncompressed from the compressed file, but does not contain the directory structure (that is, all levels of files are extracted into a directory)
L List contents of compressed files
T test compressed files
U update files to compressed files
X extract from compressed file, including directory structure
Visible, the most commonly used directives are a, l, and X.
Specific use, to give a few examples to understand:
Compress a.txt and b.txt to c.7z:
7z a c.7z a.txt b.txt (the first one after command a compresses the document name, then the file list)
Compress a.txt and B.txt to D:/program files/c.7z:
7z a d:/"program Files"/c.7z a.txt b.txt (directory name contains spaces, in quotation marks)
List the contents of c.7z:
7z l c.7z
Unzip c.7z to E:/program Files:
7z x c.7z-oe:/"program Files" (-O for Output directory with no spaces between directory paths)
This decompression contains the subordinate directory name, but does not create a new C folder under the E:/program Files, if necessary, the output directory is set to E:/program files/c, which will automatically create folder C.
If you are building a zip archive, you can set the target compression package name to C.zip directly, and it will automatically compress using the zip algorithm.
The "Go" command line uses 7zip