Linux compression, decompression, and use of read in scripts

Source: Internet
Author: User

Compression format:

Gz,bz2,xz,zip,z

Algorithm is illegal: The algorithm is different, the compression ratio will be different

Compress:filename. Z

Uncompress

The current format is more popular: Xz,bz2,gz

Gzip:. GZ

Gzip/path/to/somefile: When compression is complete, the original file is deleted

-D Decompression

-# 1-9 Specifies the compression ratio, which defaults to 6

Gunzip/path/to/somefile.gz extract also deletes the original file

Zcat viewing the contents of a compressed file, and viewing the contents of a text file without being pressed

BZIP2:. bz2

compression tool that has a greater compression ratio than gzip, as with gzip usage

Bzip2 filename.bz2

-D Decompression

-# 1-9 Specify compression ratio

-K Keep the original file

bunzip2 filename.bz2, you can also extract the command

Bzcat View the contents of the compressed file,

XZ:. XZ (compression ratio is larger, the original file will also be deleted)

XZ filename

-D

-# 1-9, default is 6

-K compression preserves the original file

Unxz Decompression

Xzcat View XZ Compressed files

The above can only compress the file, cannot compress the directory, the original file is deleted by default, only the compressed file is preserved


Zip:

Zip filename.zip file1 file2 .... : The original file is not deleted after compression

Unzip Filename.zip

Archive: Archive, archive by itself does not mean compression, zip can complete archive and compress the ability


Tar: Archive tool

-C Create an archive file

-F File.tar: Archived files for operations

TAR-CF Test.tar test*.txt Archive Test all start files, save named Test.tar

-X: Expands the archive to be used with-F, and-F is required on the last side of the parameter to specify the file

--xattrs, preserving its extended attribute information while archiving

-T: View files in the archive and use with-f

-Z: Call gzip

-ZCF: Archive and invoke gzip compression

-ZXF: Call gzip unzip to expand archive

-JCF: Call bzip2

-JXF:

-JCF: Call XZ

-jxf

Cpio: Archive Tool


Read command:

-P "Prompt" gives a hint

[[email protected] ~]# Read NAME agejerry 18[[email protected] ~]# echo $NAMEjerry [[email protected] ~]# echo $AGE 18
#!/bin/bash#echo-n "Input intergers:" Read A Becho "$A plus $B is: $[$A + $B]" ~ ~
#!/bin/bash#read-p "Input interagers" A becho "$A plus $B is: $[$A + $B]"
#!/bin/bash#read-t 5-p "Input [interagers[a=100,b=200]:" A b[-Z $A] && a=100[-Z $B] && b=200echo "$A plus $B is: $[$A + $B]"
#!/bin/bash#read-p "Three files" FILE1 FILE2 file3read-p "Destination" Destread-p "Compress[gzip|bzip2|xz]" compcase $COMP ingzip) 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 xz ${dest}.tar;; *) echo "Unknown" Exit 9;; Esacecho "$FILE 1 $FILE 2 $FILE 3 BAK is OK"


Linux compression, decompression, and use of read in scripts

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.