How to decompress or compress files in linux

Source: Internet
Author: User
We often encounter decompression of large *. zip files under linux. generally, winrar is often used to extract files directly in smb, but there may be a long decompression time and sometimes network errors. Therefore, I checked the linux decompression tool. 1. linux unzip command can decompress windo... we often encounter a large decompression * in linux *.. Therefore, I checked the linux decompression tool.
 
 
 
 
1. the linux unzip command can decompress the zip file in windows.
 
 
Unzip command
 
Syntax: unzip [option] Compressed file name. zip
 
The meanings of each option are as follows:
 
-X file list: decompress the file, but does not include the specified file.
 
-V.
 
-T whether the test file is damaged, but the pressure is not solved.
 
-D Directory: decompress the compressed file to the specified directory.
 
-Z only displays the annotation of the compressed file.
 
-N does not overwrite existing files.
 
-O overwrites existing files and does not require user confirmation.
 
-J. do not recreate the directory structure of the document and decompress all the files to the same directory.
 
Example 1: extract text.zip from the current directory.
 
$ Unzip test.zip
 
Example 2: decompress the compressed file text.zip under the specified directory/tmp. if the same file already exists, the unzip command must not overwrite the original file.
 
$ Unzip-n test.zip-d/tmp
 
Example 3: view the Directory of the compressed file.
 
$ Unzip-v test.zip
 
Zgrep command
 
The function of this command is to find a matching regular expression in a compressed file. the usage is the same as that of the grep command, except that the object operated is a compressed file. You can use the zgrep command to check whether a certain sentence exists in a compressed file.
 
 
 
 
2. run the tar command
 
Format: tar [option] [file directory list]
Function: Package and back up the file directory.
Option:
-C create a new archive file
-R: append an object to the end of the archive object
-X solve the file from the archive file
-O unlocks the file to the standard output
-V output related information during processing
-F operations on common files
-Z calls gzip to compress the archive file, and calls gzip to decompress the archive file when it is used with-x.
-Z calls compress to compress the archive file, and calls compress to decompress the archive file when it is connected to-x.
 
 
Example 1: Use tar to package files in a directory:
 
Tar-cf archive.tar foo bar # Create archive.tar from files foo and bar.
 
Example 2: list all files in the *. tar package
Tar-tvf archive.tar # List all files in archive.tar verbosely.
 
Example 3: decompress the file
Tar-xf archive.tar # Extract all files from archive.tar.
 
 
Example 4: extract the * .tar.bz2 file
 
Tar-xjvf test.tar.bz2
 
Example 5: extract the * .tar.gz file
 
Tar-xzvf test.tar.gz or tar-xzvf test.tar. z
 
 
 
 
If tar does not support the-j parameter, you can use it as follows:
 
Bzip2-d xxx.tar.bz2
 
Tar xvf xxx.tar


From andyhuabing's column
Related Article

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.