Basic concepts:
Compression: The file according to some algorithm to reduce, such as a text file content is: AAAAADDDD We can simplify it as a5d4 need to restore back, so that the original text storage needs 18 Bytes, now only need 8 bytes, greatly save space, generally speaking, the simpler the compression algorithm, The faster the compression speed, the more complex the algorithm, the higher the compression ratio [(the size before compression-the size after compression)/the size before compression).
Archive (archive): Compression can only compress the file, but not the directory, and archiving is the collection of multiple files together to form a file, so that we can put the directory, and the contents of the directory is archived together to form a file, and then we can use the tool to compress it. (Note: The archive itself is not compressed)
Compression command:
Compress:filenme.z
Uncompress
Gzip:.gz
Gzip/path/to/somefile Delete source files after compression is complete
-D: Unzip
-#: Specify the compression level, [1-9] 1 The fastest compression ratio is lowest, 9 the slowest compression ratio is the highest, the default is 6
zcat/path/to/somefile.gz View Text File contents
BZIP2:. bz2
Compression tool with a greater compression ratio than gzip
Bzip2/path/to/somefile
-D:
-#:
-K: Keep the original file when compressing
bunzip2/path/to/somefile.bz2
Bzcat
XZ:. XZ
Xz/path/to/somefile
-D
-#:
-K: Compressed retention source file
Unxz
Xzcat
Xzdec
Zip: A compressed and archived tool
Zip filename.zip FILE1 FILE2 ... : The original file is not deleted after compression
Unzip Filename.zip
Tar: Archive tool
-C: Create an archive file
-F File.tar: Archived files for operations
-X: Expand Archive
--xattrs: Preserves extended attribute information for files when archiving
-T: Do not expand the archive to directly see which files are 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:
Exercise: Write a script
From the keyboard allows the user to enter several files, the script can archive this several files into a file
Read
-P "PROMPT": Give a hint
This article from "Single Season rice" blog, declined reprint!
Linux compression and archiving