Linux decompression syntax and example

Source: Internet
Author: User

Linux decompression syntax and example

We know that there are only two types of compressed files in windows, one is zipping and the other is .rar. However, Linux can be used in different regions in Linux, and there are too few users who use .zipand .rar in linux. In addition, many Linux compression programs can only compress one file. When you want to compress a large number of files, you must first compress these files into a package using another tool, then, compress the original compression program.

At the end of lifecycle. After the tar package is generated, you can use other programs to compress it. So let's talk about the tar command first.

Tar

Syntax

Tar [-ABcdgGhiklmMoOpPrRsStuUvwWxzZ] [-B <number of blocks>] [-C <destination directory>] [-f <Backup File>] [-F <script File>] [-K <File>] [-L <media capacity>] [-N <date and time>] [-T <Template File>] [-V <volume Name>] [-X <template File>] [-<device number> <storage density>] [-- after-date = <date and time>] [-- atime-preserve] [-- backuup = <backup mode>] [-- checkpoint] [-- concatenate] [-- confirmation] [-- delete] [-- exclude = <template style>] [-- force-local] [-- group = <group Name>] [-- help] [-- ignore-failed-read] [-- new-volume-script = <script File>] [-- newer-mtime] [-- no-recursion] [-- null] [-- numeric-owner] [-- owner = <User Name>] [-- posix] [-- erve] [-- preserve-order] [-- preserve-permissions] [-- record -size = <block quantity>] [-- recursive-unlink] [-- remove-files] [-- rsh-command = <execution command>] [-- same-owner] [-- suffix = <backup character string>] [-- totals] [-- use-compress-program = <execution command>] [-- version] [-- volno-file = <No. file>] [file or directory...] </script File>
Option
Object Description
-A or-catenate Add a file to an existing backup file;
-B Set the block size;
-C or-create Create a new backup file;
-C <directory> This option is used for decompression. to extract data in a specific directory, you can use this option.
-D Record File differences;
-X or-extract or-get Restore a file from a backup file;
-T or-list List the contents of the backup file;
-Z or-gzip or-ungzip Use the gzip command to process backup files;
-Z or-compress or-uncompress Use the compress command to process backup files;
-F <Backup file> or-file = <Backup file> Specifies the backup file;
-V or-verbose Displays the instruction execution process;
-R Add a file to a compressed file;
-U Added and changed existing files to existing compressed files;
-J Supports bzip2 File extraction;
-V Displays the operation process;
-L File System Boundary settings;
-K Retain the original files and do not overwrite them;
-M The reserved file is not overwritten;
-W Confirm the correctness of the compressed file;
-P or-same-permissions Use the original file permission to restore the file;
-P or-absolute-names The file name must be an absolute name. Do not remove the "/" number before the file name;
-N <date format> or-newer = <date and time> Only Files updated on a specified date are saved to the backup file;
-Exclude = <template style> Exclude files that conform to the template style.
Instance
Tar-jtv-f restart # Check tar-xvf file.tar # decompress the tar package tar-xzvf file.tar.gz-C to decompress the directory # decompress tar.gz tar-xjvf file.tar.bz2 # decompress tar.bz2 tar-xZvf File. Z # decompress tar. Z
Zip

  Zip commandIt can be used to extract files or package files. Zipis a compressed file with the extension ". Zip" is used to compress files.

Syntax

Zip [-AcdDfFghjJKlLmoqrSTuvVwXyz $] [-B <working directory>] [-ll] [-n <character string>] [-t <date and time>] [-<compression efficiency>] [compressed file] [file...] [-I <template style>] [-x <template style>]
Option
Object Description
- Adjust the executable automatic decompression file.
-B <working directory> Specifies the directory for storing files temporarily.
-C Add comments to each compressed file.
-D Deletes a specified file from a compressed file.
-D No directory name is created in the compressed file.
-F This parameter works similarly to the specified "-u" parameter, but not only updates existing files. If some files do not exist in the compressed file, this parameter is used to add it to the compressed file.
-F Try to repair damaged compressed files.
-G Compress the file and append it to the existing compressed file, instead of creating a new compressed file.
-H Online Help.
-I <template style> Only files that meet the criteria are compressed.
-J Only the file name and its content are saved, without any directory name.
-J Delete unnecessary data before a compressed file.
-K Use a file name in MS-DOS-compatible format.
-L When compressing a file, replace the LF character with the LF + CR character.
-Ll When compressing a file, replace the LF + CR character with the LF character.
-L Display copyright information.
-M After compressing and adding a compressed file, delete the original file, that is, move the file to the compressed file.
-N <character string> Do not compress files with specific character strings.
-O Based on the file with the latest change time in the compressed file, set the change time of the compressed file to the same as that of the file.
-Q The command execution process is not displayed.
-R Recursive processing: all files and subdirectories in the specified directory are processed together.
-S Contains system and hidden files.
-T <date and time> Set the date of the compressed file to the specified date.
-T Check whether each file in the backup file is correct.
-U Change the newer file to the compressed file.
-V Displays the command execution process or version information.
-V Save the file attributes of the VMS operating system.
-W If the file name contains the version number, this parameter is only valid in the VMS operating system.
-X <template style> Exclude files that meet the criteria during compression.
-X No additional file attributes are saved.
-Y Directly Save the symbolic connection instead of the file to which the connection points. This parameter is only valid in UNIX and other systems.
-Z Add comments to the compressed file.
-$ Name of the volume on which the first compressed file is stored.
Instance

Package all the files and folders in the/home/html/directory as html.zip in the current directory:

zip -q -r html.zip /home/html

In the/home/html directory, run the following command:

zip -q -r html.zip *

Delete file a. c from the compressed file cp.zip

zip -dv cp.zip a.c
Unzip

Used to decompress a zip file

Syntax

Unzip [-cflptuvz] [-agCjLMnoqsVX] [-P <password> ][.zip file] [file] [-d <directory>] [-x <File>] Or unzip [-Z]

Option

Object Description
-C Display the extracted results on the screen and convert the characters properly.
-F Update existing files.
-L Displays the files contained in the compressed file.
-P Similar to the-c parameter, the extracted results are displayed on the screen, but no conversion is performed.
-T Check whether the compressed file is correct.
-U Similar to the-f parameter, but in addition to updating an existing file, other files in the compressed file are also extracted to the directory.
-V The execution details are displayed.
-Z Only the remarks of the compressed file are displayed.
- Perform necessary character conversion for text files.
-B Do not convert characters in text files.
-C The names of compressed files are case sensitive.
-J The original directory path of the compressed file is not processed.
-L Change all file names in the compressed file to lowercase.
-M Send the output result to the more program for processing.
-N Do not overwrite the original file during decompression.
-O You do not need to ask the user first. After unzip is executed, the original file will be overwritten.
-P <password> Use the zip password option.
-Q No information is displayed during execution.
-S Convert the blank characters in the file name to the bottom line characters.
-V Retain the file version information of VMS.
-X During decompression, the original UID/GID of the file is stored back.
-D <directory> Specifies the directory to be stored after the file is decompressed.
-X <File> Specifies which files in the. Zip compressed file are not processed.
-Z Unzip-Z is equivalent to executing the zipinfo command.
Instance
Unzip-l file.zip # view the unzip-v file.zip file contained in the compressed file # view the compressed file directory information, unzip-n file.zip-d directory to be decompressed # decompress the file

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.