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 the contents of the compressed file
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 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 Instructions
[Root@test/root] #bzcat filename.bz2 <== Read compressed file content directives
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 packaging to bzip2 compression
[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 RAR tool.
First download RAR 3.60 Beta 6 for Linux in http://www.rarlab.com/download.htm
I unzipped to/OPT, will automatically create a RAR directory. This tool can be used directly without compiling.
Create the Bin directory under the $home directory.
Create a link in the bin directory. Ln-s/opt/rar/rar rar.
You can use RAR tool compression and decompression. rar file. However, this tool is in the command mode, and in DOS the RAR operation is the same.
Turn from: http://blog.csdn.net/yuyongpeng/article/details/1818717
Application:
[Glaxy:/home/baba/mama]tar-zcvf/home/baba/mama/gege/jiejie.tar.gz Jiejie
The above jiejie.tar.gz is the target file, Jiejie is the source folder