The commonly used compression formats under Linux are:
Gz,bz2,xz,zip,z//Can only compress files can not compress the directory, if passed a directory, he will be in the directory of files compression, compression algorithm: The algorithm is different, compression ratio is also different gz:gzip, after compression for. GZ//gunzip Decompression-D: Unzip-# (# Range is 1-9): Specify compression ratio, compression ratio is smaller, compression speed faster, compressed file is larger, default is 6zcat: In the case of the decompression of the contents of the compressed text file (temporarily unzip the file to view, after the temporary file is deleted) BZ2:BZIP2, Compression for. BZ2 is more compression than gzip compression tool, for large files, BZIP2 has a great advantage, using the format approximation//compression bunzip2-d:-#:(1-9)-K: can save the original file Bzcat: If it is a text file, you can not extract directly to view XZ: After compression for. XZ Usage Similar | | Unxz,xzdec extract very small files, extract to the screen-d:-#:-c: input to the screen-K: Keep the original file Xzcat: can only compress the file, compression ratio will be more compressed one file at a time can also be compressed more than one file by default these compression commands will delete the original file when it is compressed. Only after the compressed file decompression will also delete the original compressed file, only the uncompressed file zip://Compression After the default does not delete the original file can compress the directory, but the compression ratio is not used in the format: zip specifies the compressed name of the file or directory to be compressed Eg:zip Test.zip test///Compression test directory, after compression is test.zipzip to compress multiple files together, is a compressed and archived command Unzip compressed files: Unzip the archive archive, to consolidate multiple files, the archive itself does not mean that the compression tar://Archive uncompressed files only .... tar-c: Create an archive file-F File.tar: An archive of the operation, specify the name of the compressed file, after F must take the parameter EG:TAR-CF Test.tar TEST*-XF File.tar: Expand archive--xattrs: To preserve extended property information for a file while archiving-TF File.tar: Do not expand archiving to see what files are archived and compressed:-ZCF: Call gzip, and create an archive file Eg:tar- ZCF test.tar.zip TEST/-ZXF: Archive after unzip eg:tar-zxf test.tar.zip//delete-Z option to delete -jcf: Call bzip2 and create archive-JXF: Archive after decompression -jCF: Call XZ, and create archive file-JXF: First unzip the archive  -GTF: No pressure directly look at the archived file-G can be omitted, because the system can be based on the suffix name to determine the type of decompression tar is also a very useful backup tool cpio: Make an archive or expand the archive File files or copy them out of an archive exercise: Write a script from the keyboard to let the user enter several files, the script can archive this several files into a file sum.sh//Direct interaction with the command line #!/bin/bash//echo-n "Input Intergers "//-n is for non-newline inputs read-p" input "intergers" A B//-p Direct echo "$A + $B is $[$A + $B]" #!/bin/bashread-p "thre E files: "FILE1 FILE2 file3read-p" Destination "Destread-p" Compress[gzip|bzip|xz]: "Comp case 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 3xz $ (DEST). Tar; *) echo "Unknown" Exit 9;; Esac
Compression and archiving under Linux