Linux Unzip the tar command
Tar-zcvpf/backup/home.tar.gz/home with file attribute permission compression
Tar cvpft/backup/config.tar/backup/configlist compression According to the list in the Configlist file
tar-zxvpf/software/home.tar.gz with file attribute permissions decompression
tar [-cxtzjvfppn] files and directories ....
Parameters:
-C: Create a compressed file parameter directive (the meaning of Create);
-x: Unlock the parameter instructions for a compressed file!
-T: View the files inside the Tarfile!
In particular, in the release of the parameters, c/x/t can only exist one! Cannot exist at the same time!
Because it is not possible to compress and decompress simultaneously.
-Z: Do you have the properties of gzip at the same time? i.e. do I need gzip compression?
-j: Do you have bzip2 properties at the same time? i.e. is it necessary to compress with bzip2?
-V: Files are displayed during compression! This is commonly used, but is not recommended for use in the background execution process!
-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: Use original file properties (attributes are not changed according to user)
-P: You can use absolute path to compress!
-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:
Example one: Package all the files in the/etc directory into/tmp/etc.tar
[[email protected] ~]# tar-cvf/tmp/etc.tar/etc<== only packaged, not compressed!
[[email protected] ~]# tar-zcvf/tmp/etc.tar.gz/etc<== after packing, compress with gzip
[[email protected] ~]# tar-jcvf/tmp/etc.tar.bz2/etc<== after packaging to bzip2 compression
# Note that the file name after parameter f is taken by yourself, and we are accustomed to using. Tar as a recognition.
# if the z parameter is added, the. tar.gz or. tgz represent the gzip compressed tar file ~
# If you add the J parameter, use. tar.bz2 as the file name.
# When the above instruction is executed, a warning message is displayed:
# "tar:removing leading"/"from member names" that is a special setting for absolute paths.
example two: see what files are in the/tmp/etc.tar.gz file above?
[[email protected] ~]# tar-ztvf/tmp/etc.tar.gz
# because we use gzip compression, so if you want to review the files in the tar file, < Br># will have to add Z this parameter! It's important!
example three: Extract the/tmp/etc.tar.gz file under/usr/local/src
[[email protected] ~]# cd/usr/local/src
[[ Email protected] src]# tar-zxvf/tmp/etc.tar.gz
# in the case of presets, we can unpack the archive anywhere! In this example,
# I first transform the working directory under/USR/LOCAL/SRC, and untie/tmp/etc.tar.gz,
# The Unpacked directory will be in/USR/LOCAL/SRC/ETC! In addition, if you enter/usr/local/src/etc ,
# will find that the file attributes in this directory and/etc/may be different!
Example four: under/tmp, I just want to untie the etc/passwd inside the/tmp/etc.tar.gz.
[Email protected] ~]# cd/tmp
[Email protected] tmp]# tar-zxvf/tmp/etc.tar.gz etc/passwd
# I can check the file name in the Tarfile through TAR-ZTVF, if only one file,
# can be released in this way! Notice that! The root directory within the etc.tar.gz/is taken away!
Example five: Back up all the files in the/etc/and save their permissions!
[Email protected] ~]# tar-zxvpf/tmp/etc.tar.gz/etc
# The properties of this-p are important, especially if you want to keep the properties of the original file!
Example six: In/home, more than 2005/06/01 new files are backed up
[Email protected] ~]# tar-n "2005/06/01"-ZCVF home.tar.gz/home
Example seven: I want to back up/home, etc, but don't/home/dmtsai
[Email protected] ~]# tar--EXCLUDE/HOME/DMTSAI-ZCVF myfile.tar.gz/home/*/etc
Example eight: Unpack the/etc/directly under/TMP without generating files!
[Email protected] ~]# cd/tmp
[Email protected] tmp]# TAR-CVF-etc | TAR-XVF-
# This action is a bit like cp-r/etc/tmp ~ still has its use!
Note that the output file becomes-and the input file becomes-and another | exist ~
# This represents the standard output, the standard input and the pipeline command!
# This part we'll be talking about this command again in Bash Shell and explain it to everyone!
This article is from the "@ Fast unblocked @" blog, make sure to keep this source http://speediness.blog.51cto.com/760841/1782379
Linux Unzip the tar command