In Linux, tar command stands for tape archive, the main role is to compress and decompress files.
Parameter Description:
-c create new archive
-x extract the archive
-t list the contents of compressed files
-z to use gzip to compress and decompress the file extension is usually .tar.gz
-j to use bzip2 to compress and decompress the file extension generally .tar.bzip2
show detailed procedures -v, for viewing the whole process decompression / compression file
-f archive specified
Suppose the user is currently in the home directory WinTest, the path is / home / wintest, testA folder exists, and TestC testB, while the testA test.ini of file, the file exists test1.png and test2.png testB
- In testA, a single compressed file the Test.ini
tar -cvf test.tar the Test.ini - In testB, compress all .png files, packaged as photos.tar
tar -cvf photos.tar test1.png test2.png or tar -cvf photos.tar ./*.png - In the current user's home directory, compressed folder TESTC
tar -cvf testC.tar TESTC / - View photos.tar which files are packaged
tar -tf photos.tar - In testB, all .png files, packaged as photos.tar.gz
tar -zcvf photos.tar.gz ./*.png - Decompression photos.tar
tar -xvf photos.tar - Decompression photos.tar.gz
tar -zxvf photos.tar
note:
- -c -x -t parameter in a command can only use one
- -f parameter must be the last parameter, such as -cvf, -zxf
- In addition -f must last parameter, the other parameters are not distinguished order, acting in such a -cvf and -vcf
- Parameters can be combined to write, you can write separately, for example, you can write this:
tar -c -f -v test.tar the Test.ini