Linuxreading of compressed files
· *. Z Compress program compressed files;
· *.bz2 bzip2 Program compressed files;
· *.gz gzip Program compressed files;
· *.tar The tar program to package the data, and has not been compressed;
· *.tar.gz tar program packed archives, which are compressed by gzip!
· *.zip Zip program compressed file
· *.rar rar program zip file
Compress compressed Files
[[email protected]/root]# c p/etc/man.config/root
[[email protected]/root]# compress man.config // compress man.config this file
[[email protected]/root]# compress-d Man.config.z //-d < Span style= "font-size:14px" > unzip this file
[[email Protected]/root]# uncompress man.config.z // unzip this file
when you compress with compress , if you do not release other parameters, then the original file will be later *. Replaced by Z !
gzip Compressed files and Zcat
[ [email protected]/root]# gzip [-d#] filename <== Compression and decompression
[email protected]/root]# zcat filename.gz <== Read Compressed file contents
parameter Description:
-D : Unzip the Parameters!
- R : Handles all files and subdirectories in the specified directory in a recursive process
-# : Compression level, 1 the most bad, 9 best, 6 is the default value!
[[email protected]/root]# gzip man.config // will generate man.config.gz this file
[email protected]/root]# zcat man.config.gz // will read out the contents of the Man.config
[Email protected]/root]# gzip-d man.config.gz
[Email protected]/root]# gunzip man.config.gz
unzip, generate Man.config this file
[email protected]/root]# gzip-9 man.config // compression testing This file with the maximum compression ratio !
[Email protected]/root]# gzip-r filename.gz file1 file2 file3/usr/work/school
// file1 ,file2, file3, and /usr/work/school The contents of the directory (assuming this directory exists) are compressed and then put into the filename.bz2 file .
BZIP2 Compressed Files and Bzcat
[ [email protected]/root]# bzip2 [-dz] filename <== Compression decompression instruction
[email protected]/root]# bzcat filename.bz2 <== read compressed file content Directives
parameter Description:
-D : The meaning of decompression!
-Z: Compression means!
Example:
In the same way, we've just copied the/root/man.config file as an example .
[Email protected]/root]# bzip2–z man.config
[Email protected]/root]# bzcat man.config.bz2
[Email protected]/root]# bzip2–d man.config.bz2
[Email protected]/root]# bunzip2 man.config.bz2
[Email protected]/root]# bzip2 filename.bz2 file1 file2 file3/usr/work/school
// file1 , file2 , File3 , and /usr/work/school The contents of the directory (assuming this directory exists) are compressed and then put into filename.bz2 in the file
Tar compressed files
[email protected]/root]# tar [-ZXCVFPP] filename
[email protected]/root]# Tar-n ' yyyy/mm/dd '/path-zcvf target.tar.gz source
parameter Description:
-Z : Do you have the properties of gzip at the same time?
-x: Unlock a compressed file parameter command!
-T: View the files inside the Tarfile!
-C: Create a parameter directive for a compressed file
-V: Files are displayed during compression!
-F: Use the file name, please note, after F to immediately answer the file name Oh! Don't add any more arguments!
For example, using "TAR-ZCVFP tfile sfile" is the wrong way to write
"TAR-ZCVPF tfile sfile" Just right!
-P: The original attribute of the original file is used (the attribute will not change according to the user)
-P: Absolute path can be used
-N: Newer than next date (YYYY/MM/DD) will be packaged in the new file!
--exclude file: In the process of compression, do not package file!
Example:
[email protected]/root]# tar-cvf directory.tar directory
// Package directory consolidation into one file only
[email protected]/root]# tar-zcvf directory.tar.gz directory
In addition to packaging the directory, the gzip compression
[email protected]/root]# TAR-ZCVF filename.tar.gz/home/test/*
Package the files in this directory /home/test/ and compress them into a filename.tar.gz file.
[[email protected]/root]# tar-jcvf/tmp/etc.tar.bz2/etc <= = after packing, to bzip2 Compression
[email protected]/root]# tar-xvf Directory.tar
To unpack the tar , be aware that there is no gzip (. Tar instead of. tar.gz), so just use –XVF! No need to add Z, otherwise it will show a problem!
[email protected]/root]# tar-zxvf directory.tar.gz
This is the result of compression with Gzip Plus! So need to add –z yo!
[email protected]/root]# TAR–ZTVF directory.tar.gz
this T can be used to view the archive information in tar! Without having to untie him!
[email protected]/root]# TAR-ZCVPF home.tar.gz/home
The file in the compressed file is the absolute path.
Note that when you use this p parameter, do not add p after F, because
After F to immediately answer the file name!
[email protected]/root]# tar-n ' 2002/06/25 '-ZCVF home.tar.gz/home
The above is that in the home/home directory, more than 2002/06/25 of new files will be packaged into home.tar.gz this file!
[email protected]/root]# tar-zcvf host.tar.gz/--exclude/mnt--exclude/proc
The above means that all the data from the root directory is packaged in the host.tar.gz file, but/mnt and/proc are not packaged!
[email protected]/root]# TAR-CVF-Home | tar-xvf-
the above means " home/home" after packaging, directly extracted under the/root! Hey No need to set up an intermediate file again! However, using the above syntax is best used for "absolute path", the comparison will not be a problem! This is a good way to avoid creating intermediate files!
Zip and Unzip compressed files
[email protected]/root]# zip-r myfile.zip./* // All files and folders under the current directory are compressed into myfile.zip files, and-R indicates that all files in the subdirectory are compressed recursively.
[email protected]/root]# zip-d myfile.zip smart.txt // Delete smart.txt files in compressed files
[email protected]/root]# zip-m myfile.zip./rpm_info.txt // To add a rpm_info.txt file to a myfile.zip in a compressed file
[email protected]/root]# unzip-o-d/home/sunny myfile.zip // Unzip the myfile.zip file to/home/sunny/
RAR Compressed Files
Most compressed packages are now in RAR format, so a RAR tool is required.
First download RAR 3.60 Beta 6 for Linux in http://www.rarlab.com/download.htm
I unzipped to/opt, will automatically build the 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 tools to compress and decompress. rar files. However, this tool is command mode, and the RAR operation under DOS is the same.