Linux Unzip command

Source: Internet
Author: User

Follow the format: Zip file compression: Format: Zip compressed filename Source file Example: topwqp:japan wangqiupeng$ ls
Cangls
Topwqp:japan wangqiupeng$ zip cangls.zip Cangls
adding:cangls/(stored 0%)
Topwqp:japan wangqiupeng$ ls
Cangls cangls.zip Topwqp:japan wangqiupeng$
Zip Compressed directory: Format: Zip-r compressed file name Source Directory example:topwqp:linux_training wangqiupeng$ ls
HARDLK1 HARDLK2 Japan Softlink softlk
Topwqp:linux_training wangqiupeng$ Touch Japan/cangls
Topwqp:linux_training wangqiupeng$ Touch Japan/longls
Topwqp:linux_training wangqiupeng$ Touch Japan/boduols
Topwqp:linux_training wangqiupeng$ Zip-r japan.zip Japan
adding:japan/(stored 0%)
Adding:japan/boduols (stored 0%)
adding:japan/cangls/(stored 0%)
Adding:japan/cangls.zip (stored 0%)
Adding:japan/longls (stored 0%)
topwqp:linux_training wangqiupeng$ ls
HARDLK1 Japan Softlink
HARDLK2 Japan.zip softlk
Topwqp:linux_training wangqiupeng$
Decompression in ZIP Format: very simple: Unzip compressed file name example:Topwqp:linux_training wangqiupeng$ Unzip Japan.zip
Archive:japan.zip
Replace Japan/boduols? [Y]es, [N]o, [A]ll, [N]one, [R]ename:y
Extracting:japan/boduols
Replace Japan/cangls.zip? [Y]es, [N]o, [A]ll, [N]one, [R]ename:y
Extracting:japan/cangls.zip
Replace Japan/longls? [Y]es, [N]o, [A]ll, [N]one, [R]ename:y
Extracting:japan/longls
topwqp:linux_training wangqiupeng$ ls
HARDLK1 Japan Softlink
Hardlk2 japan.zip softlk topwqp:linux_training wangqiupeng$
Advantages of this command: Zip file compression in Linux and Windows compressed ZIP format consistent
2:. gz format compression and decompression compression command: gzip source file This command executes: The source file disappears only after the compressed file exists example:topwqp:linux_training wangqiupeng$ Touch ABC
Topwqp:linux_training wangqiupeng$ gzip ABC
topwqp:linux_training wangqiupeng$ ls
abc.gz Hardlk2 Softlink
HARDLK1 Japan SOFTLK
Topwqp:linux_training wangqiupeng$
If you want to keep the source file: You can use output redirection in this way: gzip-c source files > Compressed filestopwqp:linux_training wangqiupeng$ ls
ABC Hardlk2 Softlink
HARDLK1 Japan SOFTLK
topwqp:linux_training wangqiupeng$ gzip-c ABC > abc.gz
topwqp:linux_training wangqiupeng$ ls
ABC HARDLK1 Japan SOFTLK
abc.gz Hardlk2 Softlink
Topwqp:linux_training wangqiupeng$
The compression command with the directory is as follows: Gzip-r source file Example:topwqp:linux_training wangqiupeng$ ls
ABC HARDLK1 Japan SOFTLK
abc.gz Hardlk2 Softlink
Topwqp:linux_training wangqiupeng$ CD Japan
Topwqp:japan wangqiupeng$ ls
Boduols Cangls Longls
Topwqp:japan wangqiupeng$ CD.
Topwqp:linux_training wangqiupeng$ gzip-r Japan
topwqp:linux_training wangqiupeng$ ls
ABC HARDLK1 Japan SOFTLK
abc.gz Hardlk2 Softlink
Topwqp:linux_training wangqiupeng$ CD Japan
Topwqp:japan wangqiupeng$ ls
boduols.gz Cangls longls.gz
Topwqp:japan wangqiupeng$
Cangls is not compressed because it is a directory:Opwqp:japan wangqiupeng$ Ls-l
Total 16
-rw-r--r--1 Wangqiupeng Staff 22:32 boduols.gz
Drwxr-xr-x 2 Wangqiupeng Staff 22:32 Cangls
-rw-r--r--1 Wangqiupeng Staff 22:32 longls.gz
Topwqp:japan wangqiupeng$

Uncompressed command format: gzip-d compressed file
or Gunzip Compressed files
If you are extracting a directory, there are many compressed files in the directory: Gunzip-r compressed directory
3:BZ2 Decompression: bz2 format compression: bzip2 source file This command will delete the source file if you want to not delete the source files can be used as follows: Bzip2-k source file tips:bzip2 not be able to compress the directory
Decompression: bzip2-d compressed file bunzip2 Compressed file example:Topwqp:linux_training wangqiupeng$ bzip2 ABC
topwqp:linux_training wangqiupeng$ ls
ABC.BZ2 HARDLK1 Japan SOFTLK
abc.gz Hardlk2 Softlink
Topwqp:linux_training wangqiupeng$ bunzip2 abc.bz2
topwqp:linux_training wangqiupeng$ ls
ABC HARDLK1 Japan SOFTLK
abc.gz Hardlk2 Softlink
Topwqp:linux_training wangqiupeng$
There are also two compression formats that do not speak tomorrow: tar.gz format decompression:
TAR-CVF package file name source file option:-C Package-V display procedure-f specifies the file name after packaging
topwqp:linux_training wangqiupeng$ ls
Abc Hardlk1Japan Softlk
Abc.gz Hardlk2Softlink
Topwqp:linux_training wangqiupeng$ TAR-CVF Japan.tar Japan
A Japan
A japan/boduols.gz
A Japan/cangls
A japan/longls.gz
topwqp:linux_training wangqiupeng$ ls
Abc Hardlk1Japan Softlink
Abc.gz Hardlk2Japan.tarSoftlktopwqp:linux_training wangqiupeng$
Re-compression can:Topwqp:linux_training wangqiupeng$ gzip Japan.tar
topwqp:linux_training wangqiupeng$ ls
ABC hardlk1Japan softlink
abc.gz hardlk2japan.tar.gzsoftlk
Topwqp:linux_training wangqiupeng$
Unzip: TAR-XVF filename where x represents the decompression example:opwq p:linux_training wangqiupeng$ ls
abc hardlk1 japan.tar softlk
Abc.gz hardlk2 softlink
Topwqp: Linux_training wangqiupeng$ tar-xvf japan.tar
x japan/
x japan/boduols.gz
x japan/cangls/
x japan/ longls.gz
topwqp:linux_training wangqiupeng$ ls
abc hardlk1 Japan softlink abc.gzhardlk2japan.tarsoftlk

The above is packaged and then compressed: The following command can be packaged directly after the compression command as follows: TAR-ZCVF compressed package name. tar.gz Source file Option:-Z: Compressed to. tar.gz format
Topwqp:linux_training wangqiupeng$ TAR-ZCVF japan.tar.gz Japan
A Japan
A japan/boduols.gz
A Japan/cangls
A japan/longls.gz
topwqp:linux_training wangqiupeng$ ls
ABC HARDLK1Japan softlink abc.gzhardlk2japan.tar.gzsoftlkThe extract command is as follows: TAR-ZXVF the package name. tar.gz option:-x: Unzip the. tar.gz format where the-c file is located, representing the extract to the specified location
Topwqp:linux_training wangqiupeng$ tar-zxvf japan.tar.gz-c./tmp
X japan/
X japan/boduols.gz
X japan/cangls/
X japan/longls.gz
topwqp:linux_training wangqiupeng$ ls
ABC hardlk1Japan softlink tmp
abc.gz hardlk2japan.tar.gzsoftlk
topwqp:linux_training wangqiupeng$ CD tmp
Topwqp:tmp wangqiupeng$ ls
Japan
Topwqp:tmp wangqiupeng$

. TAR.BZ2 compression Format:
If it is a TAR-JCVF compressed package name, the tar.bz2 source file is extracted to the specified location command:


Decompression: TAR-JXVF compressed package name. Tar.bz2-x: Uncompressed. tar.bz2 format
Unzip the command to the specified directory as follows: TAR-JXVF compressed file name. TAR.BZ2-C/Catalogue

TAR-ZTVF compressed file name. The tar.gz-z represents no pressure and displays only the contents of the compressed files.
topwqp:linux_training wangqiupeng$ TAR-ZTVF japan.tar.gz
Drwxr-xr-x 0 Wangqiupeng Staff 0 22:50 japan/
-rw-r--r--0 Wangqiupeng Staff 22:32 japan/boduols.gz
Drwxr-xr-x 0 Wangqiupeng Staff 0 22:32 japan/cangls/
-rw-r--r--0 Wangqiupeng Staff 22:32 japan/longls.gz
Topwqp:linux_training wangqiupeng$

If you want to compress multiple files at the same time, multiple filenames are separated by spaces:Topwqp:linux_training wangqiupeng$ TAR-ZCVF japan_abc.tar.gz Japan ABC
A Japan
A japan/boduols.gz
A Japan/cangls
A japan/longls.gz
A ABC
topwqp:linux_training wangqiupeng$ ls
Abc JapanSoftlk
Abc.gz Japan.tar.gzTmp
Hardlk1 Japan_abc.tar.gz
Hardlk2 Softlink
Topwqp:linux_training wangqiupeng$ TAR-ZTVF japan_abc.tar.gz
Drwxr-xr-x 0 Wangqiupeng Staff 0 22:50 japan/
-rw-r--r--0 Wangqiupeng Staff 22:32 japan/boduols.gz
Drwxr-xr-x 0 Wangqiupeng Staff 0 22:32 japan/cangls/
-rw-r--r--0 Wangqiupeng Staff 22:32 japan/longls.gz
-rw-r--r--0 Wangqiupeng Staff 0 22:45 ABC
Topwqp:linux_training wangqiupeng$

Linux Unzip command

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.