A detailed example of compression decompression commands under Linux

Source: Internet
Author: User
Tags bz2 pack

Example: compressing the contents of the current directory as a xxx.zip file

Zip-r xxx.zip./*

Unzip the zip file to the current directory

Unzip Filename.zip

============================

Another: Some servers do not install the ZIP package does not execute the zip command, but basically can be used with the tar command, the example is as follows:

tar-zcvf/home/zdzlibs.tar.gz/home/zdz/java/zdzlibs/

============================

Linux zip command

Zip-r myfile.zip./*
All files and folders under the current directory are compressed into myfile.zip files, and-R indicates that all files in the subdirectory are compressed recursively.

2.unzip
Unzip-o-d/home/sunny Myfile.zip
Unzip the Myfile.zip file to/home/sunny/
-O: Overwrite the file without prompting;
-d:-d/home/sunny indicates that the file is extracted to the/home/sunny directory;

3. Other
zip-d Myfile.zip Smart.txt
To delete a smart.txt file in a compressed file
Zip-m Myfile.zip./rpm_info.txt
To add a rpm_info.txt file to a myfile.zip in a compressed file
-------------------------------------------------------------------------------

To compress a file using Zip, type the following command at the shell prompt:

Zip-r Filename.zip Filesdir

In this example, Filename.zip represents the file you created, and Filesdir represents the directory where you want to place the new zip file. The-r option specifies that you want to recursively (recursively) include all files included in the Filesdir directory.

To extract the contents of a zip file, type the following command:

Unzip Filename.zip

You can use the zip command to work with multiple files and directories at the same time by listing them one after the other with a space interval:

Zip-r filename.zip file1 file2 file3/usr/work/school

The above command compresses the contents of the File1, File2, File3, and/usr/work/school directories (assuming this directory exists) and then puts them in the Filename.zip file.

A detailed description of the tar command

-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 stand-alone commands, which use one of the compression decompression, and can be used with other commands but only one. The following parameters are optional when compressing or extracting files as needed.

-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

The following parameter-F is required

-F: Use the file name, remember that this parameter is the last parameter, can only be followed by the file name.

# TAR-CF All.tar *.jpg

This command is to make all. jpg files into a package named All.tar. -C is the file name that represents the generation of a new package,-f specifies the package.

# TAR-RF All.tar *.gif

This command adds all the. gif files to the All.tar package. -R is meant to increase the file.

# Tar-uf All.tar logo.gif

This command is to update the original tar package All.tar in the logo.gif file,-U is to indicate the meaning of the update file.

# TAR-TF All.tar

This command is to list all the files in the All.tar package,-T is to list the meaning of the file

# TAR-XF All.tar

This command is to solve all the files in the All.tar package,-T is to untie the meaning

Compression

TAR–CVF Jpg.tar *.jpg//package all JPG files in the directory into tar.jpg

TAR–CZF jpg.tar.gz *.jpg//pack all JPG files in the directory into Jpg.tar and compress them in gzip to generate a gzip compressed package named jpg.tar.gz

TAR–CJF jpg.tar.bz2 *.jpg//pack all JPG files in the directory into Jpg.tar and compress them in bzip2 to generate a bzip2 compressed package named jpg.tar.bz2

TAR–CZF jpg.tar.z *.jpg//pack all JPG files in the directory into Jpg.tar and compress them in compress to generate a umcompress compressed package named Jpg.tar.z

RAR a jpg.rar *.jpg//rar format compression, you need to download RAR for Linux first

Zip jpg.zip *.jpg//zip format compression, need to download zip for Linux First

Extract

TAR–XVF File.tar//Unpacking the TAR Package

TAR-XZVF file.tar.gz//Decompression tar.gz

TAR-XJVF file.tar.bz2//Decompression tar.bz2

TAR–XZVF file.tar.z//Unzip tar. Z

Unrar e file.rar//decompression rar

Unzip File.zip//Unzip zip

A detailed example of compression decompression commands under Linux

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.