Linux---Decompression

Source: Internet
Author: User

One, compression, decompression command

Command format: gz/ba2/xz/zip/z

Compress/uncompress is ancient, not used at present.

The most commonly used xz/bz2/gz is now.

Second, the common compression command detailed

1. Gzip:. GZ cannot compress the catalog

Gzip/path/to/somefile: The original file will be deleted after compressing

-D: means the decompression of the equivalent OP gunzip

-#: #取值为1-9, default is 6 specify compression ratio

Zcat: View compressed files under the condition of no pressure, direct use of cat display garbled;

Gunzip: Unzip

Gunzip/path/to/somefil: The original file will be deleted when the decompression is complete

2, bzip2:.bz2 cannot compress the directory

Greater compression ratio than gzip

Bzip/path/to/somefile: The original file will be deleted

-d/pathto/somefile: The original file will be deleted

-#: #取值为1-9, default is 6 specify compression ratio

-K: Keep the original file when compressing

BUNZIP2: Unzip, use with-D

Bzcat: View compressed files under the condition of no pressure, direct use of cat display garbled;

3, XZ:.XZ cannot compress the directory

-D: Unzip

-#: #取值为1-9, default is 6 specify compression ratio

-K: Keep the original file when compressing

Xzdec decompression command; The file name is displayed on the screen (basic)


4, Zip:.zip retain the original file; that is, archive and compression, compression ratio of small

Zip filename.zip file1 file2 ...

Unzip File.zip

5. Tar: Archive tool, do not compress

-C: Create an archive file

-F File.tar: Archived files for operations

SUCH:TAR-CF Aa.tar aa*.txt

-XF: Expand: TAR-XF Aa.tar Archive file will not be deleted after decompression

--xattrs: Preserve extended attribute information for files while archiving

-T: Do not expand Archiving, view archived content and use- f together

-TF:TAR-TF Aa.tar Don't expand the archive to see what's archived

-ZCF: Archive and invoke gzip compression

-ZXF: Call gzip to unzip and expand Archive,-Z option to omit

-jcf:bzip2

-JXF:

-jcf:xz

-JXF:

With the above command: archive first and then compress

6, Cpio: Make archive or recall archive; very old file with a function similar to tar

Third, supplementary

Using scripts to implement archiving

#! /bin/bash
#
read-p "Enter three paths to compress files" file1 file2 file3
read-p "stored path and name" Dest
#例如: Text/aa
read-p "input compression type GZIP|BZIP2|XZ;" Comp
Case $come in
gzip)
tar-zcf ${dest}.tar.gz $file 1 $file 2 $file 3
;;
bzip2)
tar-jcf ${dest}.tar.bz2 $file 1 $file 2 $file 3
;;
XZ)
tar-cf ${dest}.tar $file 1 $file 2 $file 3
ZX ${dest}.tar
;;
*)
echo "Wrong input"
Exit:9
;;
Esca





Linux---Decompression

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.