Linux compression and decompression (zip, unzip, tar) detailed

Source: Internet
Author: User

Linux compression and decompression (zip, unzip, tar) detailed

2012-05-09 13:58:39| Category: Linux | Tags: Linux zip unzip tar linux command detailed | report | font size Subscription

Download Lofter my photo book |
Recently often on the Linux packaging compression decompression, collected from the Internet and combined with their own common, share with you under, nonsense not much to say, into the topic.
1, Zip compression
If you are compressing several files directly, you can use the command zip newfilename.zip filename1 filename2, but in general it will compress a folder or directory, use the command zip-r newfilename.zip file1 File2. If the folder contains too many files, you can use the-Q option, not the actual compression process, i.e. Zip-q-R newfilename.zip file1 file2.
Generally speaking, the-Q option and the-r option are sufficient, if you want to know more detailed, the article at the end of the detailed.
Example:
Compress the Test1 folder and Test2.txt under the/root/test folder to Aaa.zip
Under the/root/test directory, execute the command
Zip-q-R aaa.zip test1 Test2.txt
Ok! Compression Complete!

2, Unzip decompression
In general, the options commonly used with the unzip command are the-O and-D options, and the rest can be viewed in a detailed
-o option to overwrite the original file directly without asking the user
-d option allows the user to specify an extract to the specified directory
Example:
In the/root/test/directory, there are aaa.zip compressed files
If you want to overwrite the original test1 and Test2.txt, execute the command
Unzip-o Aaa.zip
If you want to keep the original file and store the extracted files in the/root/test2 directory, execute the command
Unzip-o-d/root/test2/./aaa.zip

3. Tar command
The combined options for commonly used tar commands are
TAR-XZVF filename.tar.gz
TAR-CZVF filename.tar.gz file1 file2 ...
The-f option must appear at the end of the option parameter

-C: Create compressed archives
-X: Unzip
-T: View content
-r: Append files to the end of a compressed archive file
-U: Update files in original compressed package
These five are independent options, compressed decompression to use one, can be used with other options, but these 5 can only appear in one of the

-V: Compress to display files during decompression
-F: Use file name, note, F option must be followed with the document name cannot be followed by other options, know why f option, always in the last one of the parameter options appears
-j: Do you have bzip2 properties at the same time? i.e. is it necessary to compress with bzip2?
-P: Use original file properties (attributes are not changed according to user)
-P: You can use absolute path to compress!
-N: Newer than next date (YYYY/MM/DD) will be packaged in the new file!
--exclude file: In the process of compression, do not package file!

Personal feeling the tar command is relatively powerful, and under Linux, the TAR command is much more used than zip.


Zip command explanation
-a convert the file to ASCII mode
-F attempt to repair corrupted compressed file
-H Display Help interface
-M after compressing the file, delete the source file
-N specific string does not compress files with a specific trailing string
-O to set the latest change time for all files in the compressed file to the time of compression
-Q Quiet mode, does not show the execution of instructions during compression
-R processes all subdirectories and files in the specified directory
-S contains system files and implied files (S is uppercase)
-T date sets the last modified date of the compressed file to the specified date, and the date format is mmddyyyy

Unzip detailed
-C Displays the extracted results to the screen and converts the characters appropriately.
-F Updates an existing file.
-L Displays the files contained within the compressed file.
-P, similar to the-c parameter, displays the results of the decompression to the screen, but does not perform any conversions.
-T checks that the compressed file is correct.
-U is similar to the-f parameter, but in addition to updating existing files, other files in the compressed file are extracted to the directory.
-V performs yes when the detailed information is displayed.
-Z Displays only the memo text of the compressed file.
-A necessary character conversion for the text file.
-B Do not convert the text file to character.
The file names in the-C compressed file are case sensitive.
-J does not handle directory paths that are contained in compressed files.
-L Changes all the file names in the compressed file to lowercase.
-M sends the output to the more program processing.
-N Do not overwrite the original file when extracting.
-O do not need to ask the user first, unzip overwrite the original file after execution.
-p< password > password using zip option.
-Q does not display any information when executing.
-S converts white space characters in the file name to baseline characters.
-V retains the file version information for the VMS.
-X Unzip while the original uid/gid of the file is stored back.
-d< directory > Specifies the directory to be stored after the file has been decompressed.
-x< file > Specifies which files in the. zip archive are not processed.
-Z unzip-z equals execute zipinfo Instruction

Linux compression and decompression (zip, unzip, tar) detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.