The following is from: Amin http://www.apelearn.com/study_v2/chapter11.html, the commonly used to write, the feeling can be;
Just compress and unzip the tool: Gzip Tool:
Just remember these parameters when you use them: NOTE: gzip cannot compress the directory;
- -D, which indicates decompression, without adding parameters when compressing;
- -K, which indicates keep, if not added, the original file disappears when it is compressed or decompressed, and the original file does not disappear when added –k;
After compressing the file, the suffix name is. gz, as in the following example:
gzip -k hello.c[email protected]:lshello.c hello.c.gz
Unzip:
gzip -D-k hello.c.gz [email protected]:lshello.c hello.c.gz
BZIP2 Tools:
Its usage is similar to the above tools, we remember these three parameters: note: bzip2 also not to compress the directory;
- -Z means compression; can be omitted;
- -d means decompression;
- -K, which indicates keep, if not added, the original file disappears when it is compressed or decompressed, and the original file does not disappear when added –k;
When compressing, it compresses the suffix of the file after it has increased. bz2; examples are as follows:
bzip2 -z hello.c[email protected]:lshello.c.bz2
Unzip:
bzip2 -d hello.c.bz2 [email protected]:lshello.c
Packaged compression: The Tar tool:
Tar itself is a packaging tool, but it can also be compressed, remember the above mentioned two tools can not be compressed directory, how to do??? Workaround: We can first package a directory into a file, and then compress; so use tar to do it;
We just need to remember the following parameters to be able to;
-X: Unpacking or decompressing
-C: Build a tar package or zip file package
-Z: Simultaneously with gzip compression
-j: Simultaneous compression with bzip2
-T: View the files inside the tar package
-V: Visualize
-F: followed by the file name, compressed with "-F file name", meaning the compressed file name is filename, decompression with "-f filename", meaning is to extract filename. Note that if you have multiple parameter combinations with "-F", write "-F" to the last face.
Example: Use gzip compression after packaging:
tar -czvf dir1. Tar . GZ dir1dir1/dir1/hello.c[email protected]:lsdir1 dir1. tar. GZ dir2 hello.c
Decompression and unpacking;
tar -xvf dir1. Tar . GZ //(in fact, it doesn't matter if you add Z-parameters, I see others are added) Dir1/dir1/hello.c[email protected]:~/trial$
To view the contents of a compressed package:
tar -tf dir1. Tar . GZ dir1/dir1/hello.c
Know these, usually use is enough;
Linux under Compression and packaging tools--gzip, bzip2 and tar;