tar [-cxtzjvfppn] files and directories ....
Parameters:
-C: Create a compressed file parameter instruction (create meaning);
-x: Unlock a parameter command 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! Not exist at the same time!
Because it is not possible to compress and decompress at the same time.
-Z: Do you have gzip properties at the same time? Is that the need to use gzip compression?
-j: Do you have bzip2 properties at the same time? That is to use bzip2 compression?
-V: Display files during compression! This is commonly used, but is not recommended for use in the background execution process!
-F: Use file name, please note that after F to immediately receive 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 properties of the original file (properties will not be changed according to the user)
-P: You can use absolute paths to compress!
-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:
Example one: Package all the files in the/etc directory into a/tmp/etc.tar
[Root@linux ~]# tar-cvf/tmp/etc.tar/etc<== only packaged, not compressed!
[Root@linux ~]# tar-zcvf/tmp/etc.tar.gz/etc<== after packaging, gzip compressed
[Root@linux ~]# tar-jcvf/tmp/etc.tar.bz2/etc<== after packaging to bzip2 compression
# Note that the file name after the parameter F is taken by itself, and we are accustomed to using the. Tar as an identification.
# If you add the z parameter, the. tar.gz or. tgz to represent the gzip-compressed tar file ~
# If you add the J parameter, use the. tar.bz2 as the file name.
# The above instruction will display a warning message when it is executed:
# "tar:removing leading"/"from member names" is a special set of absolute paths.
Example two: What documents are available in the above/tmp/etc.tar.gz document?
[Root@linux ~]# tar-ztvf/tmp/etc.tar.gz
# Since we use gzip compression, we need to check the files in the tar file
# We're going to have to add the Z parameter! It's very important!
Example three: Unzip the/tmp/etc.tar.gz file under/USR/LOCAL/SRC
[Root@linux ~]# CD/USR/LOCAL/SRC
[Root@linux src]# tar-zxvf/tmp/etc.tar.gz
# in the preset case, we can release the compressed file anywhere! In this example,
# I first transform the working directory underneath the/USR/LOCAL/SRC and unlock the/tmp/etc.tar.gz,
# then untie the catalog will be in/USR/LOCAL/SRC/ETC! In addition, if you enter the/USR/LOCAL/SRC/ETC
# you will find that the file attributes in this directory may be different from the/etc/.
Example four: under/tmp, I just want to untie the etc/passwd in the/tmp/etc.tar.gz.
[Root@linux ~]# Cd/tmp
[Root@linux 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
# you can make it through this way! Notice that! The root directory within the etc.tar.gz/was taken away!
Example five: Back up all the files in the/etc/and save their permissions!
[Root@linux ~]# Tar-zxvpf/tmp/etc.tar.gz/etc
# This property of-p is important, especially if you want to preserve the properties of the original file!
Example six: In/home, a new file is backed up in 2005/06/01
[Root@linux ~]# tar-n "2005/06/01″-ZCVF home.tar.gz/home
Example seven: I want to back up/home,/etc, but don't/home/dmtsai
[Root@linux ~]# TAR–EXCLUDE/HOME/DMTSAI-ZCVF myfile.tar.gz/home/*/etc
Example eight: The/etc/package will be unpacked directly to the bottom of/tmp, without producing a file!
[Root@linux ~]# Cd/tmp
[Root@linux tmp]# tar-cvf–/etc | TAR-XVF-
# This action is a bit like cp-r/etc/tmp ~ still has its use!
# The place to note is that the output file becomes – and the input file becomes – and there is a | exist ~
# This separately represents standard output, standard input and Pipeline command!
# This part we'll be talking about again when we Bash the shell and explain it to everyone again??? /p>
Uncompressed: TAR-CVF Out.tar 1.out 2.out 3.outgz compression with: TAR-CZVF out.tar.gz 1.out 2.out 3.outbz2 compression with: TAR-CJVF out.tar.bz2 1.ou T 2.out 3.out output filename is written in front of