reading of Linux compressed files
· *. Z Compress program compressed file;
· *.BZ2 bzip2 program compressed files;
· *.GZ gzip program compressed file;
· The data packaged by the *.tar tar program has not been compressed;
· *.tar.gz The TAR program's packaged files, which are compressed by gzip.
· *.zip Zip Program compressed file
· *.rar RAR Program Compressed file
Compress Compressed Files
[root@test/root]# cp/etc/man.config/root
[root@test/root]# compress man.config //compressed Man.config this file
[root@test/root]# compress-d man.config.z //-d Unzip this file
[root@test/root]# uncompress man.config.z //Unzip this file
When you compress with compress, if no other parameters are given, the original file will be later *. Replaced by Z.
gzip Compressed files and Zcat
[root@test/root]# gzip [-d#] filename <== compression and decompression
[root@test/root]# zcat filename.gz <== Read Compressed file contents
Parameter description:
-D: the extracted parameters.
-R: Recursive processing of all files and subdirectories under the specified directory
-#: Compression level, 1 bad, 9 best, 6 is the default value.
[root@test/root]# gzip Man.config //will produce man.config.gz this file
[root@test/root]# zcat man.config.gz //will read out the contents of Man.config
[root@test/root]# gzip-d man.config.gz
[root@test/root]# gunzip man.config.gz
Unzip, generate man.config this file
[root@test/root]# gzip-9 man.config //Compression testing this file with a maximum compression ratio.
[root@test/root]# gzip-r filename.gz file1 file2 file3/usr/work/school
The contents of the File1, File2, File3, and/usr/work/school directories (assuming this directory exists) are compressed and put into the filename.bz2 file
Bzip2 Compressed files and Bzcat
[root@test/root]# bzip2 [-dz] filename <== compression decompression Instruction
[root@test/root]# bzcat filename.bz2 <== Read compressed file content instructions
Parameter description:
-D: The meaning of decompression.
-Z: Meaning of compression.
Example:
Again, we take the/root/man.config file, which we just copied, as an example.
[root@test/root]# bzip2–z Man.config
[root@test/root]# Bzcat man.config.bz2
[root@test/root]# bzip2–d man.config.bz2
[root@test/root]# bunzip2 man.config.bz2
[root@test/root]# bzip2 filename.bz2 file1 file2 file3/usr/work/school
The contents of the File1, File2, File3, and/usr/work/school directories (assuming this directory exists) are compressed and put into the filename.bz2 file
Tar Compressed file
[root@test/root]# tar [-ZXCVFPP] filename
[root@test/root]# tar-n ' yyyy/mm/dd '/path-zcvf target.tar.gz source
Parameter description:
-Z: Whether to have gzip properties at the same time.
-X: Unlocks a parameter instruction for a compressed file.
-T: View the files inside the tarfile.
-C: Create a parameter command for a compressed file
-V: Displays the file during compression.
-F: Use file name, please note that after F to immediately pick up the file name Oh. Don't add any more parameters.
For example, the use of "TAR-ZCVFP tfile sfile" is the wrong way to write
"TAR-ZCVPF tfile sfile" is right.
-P: Use the original property of the original file (properties are not changed according to the user)
-P: You can use absolute paths
-N: Newer than the following date (YYYY/MM/DD) will be packaged into the newly created file.
--exclude file: Do not package file in the process of compression.
Example:
[root@test/root]# TAR-CVF Directory.tar Directory
Package catalog consolidation into one file only
[root@test/root]# TAR-ZCVF directory.tar.gz Directory
In addition to packaging the directory, at the same time with gzip compression
[root@test/root]# TAR-ZCVF filename.tar.gz/home/test/*
Pack and compress the files/home/test/this directory into a filename.tar.gz file.
[root@test/root]# tar-jcvf/tmp/etc.tar.bz2/etc <== after packing, to bzip2 Compress
[root@test/root]# TAR-XVF Directory.tar
To unpack the tar, note that you do not have the effect of gzip (. Tar instead of. tar.gz), so just use –XVF. You do not need to add Z, otherwise it will show a problem.
[root@test/root]# TAR-ZXVF directory.tar.gz
This is the result of a compression with gzip plus. So you need to add –z yo.
[root@test/root]# TAR–ZTVF directory.tar.gz
This t can be used to view the file information in tar. Without having to untie him.
[root@test/root]# TAR-ZCVPF home.tar.gz/home
The file in the compressed file is an absolute path.
Please note that when using this p parameter, do not add p to the back of F, because
Immediately after the F to receive the file name to do OH.
[root@test/root]# tar-n ' 2002/06/25 '-ZCVF home.tar.gz/home
It says that in the/home directory, new files are packaged into the home.tar.gz file than the 2002/06/25 day.
[root@test/root]# TAR-ZCVF host.tar.gz/--exclude/mnt--exclude/proc
It says that all of the data in the root directory is packaged into the host.tar.gz file, but/mnt and/proc are not packaged.
[root@test/root]# TAR-CVF-/home | tar-xvf-
The above means "after packing/home, directly unzip under/root." Hey There is no need to establish an intermediate file again. However, using the above syntax is best used "absolute path", the comparison is not a problem. This is a good way to avoid creating intermediate files.
zip and unzip compressed files
[root@test/root]# zip-r myfile.zip. ///Compress all files and folders in the current directory into Myfile.zip files,-R for all files under the recursive compression subdirectory.
[root@test/root]# zip-d myfile.zip smart.txt //delete smart.txt files in compressed files
[root@test/root]# zip-m myfile.zip./rpm_info.txt //Add Rpm_info.txt file to Myfile.zip in compressed file
[root@test/root]# unzip-o-d/home/sunny myfile.zip //extract myfile.zip files to/home/sunny/
rar Compressed Files
Now most of the online compression package is in RAR format, so need a