Linux commands to learn -tar command

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

  1. In testA, a single compressed file the Test.ini
    tar -cvf test.tar the Test.ini
  2. In testB, compress all .png files, packaged as photos.tar
    tar -cvf photos.tar test1.png test2.png or tar -cvf photos.tar ./*.png
  3. In the current user's home directory, compressed folder TESTC
    tar -cvf testC.tar TESTC /
  4. View photos.tar which files are packaged
    tar -tf photos.tar
  5. In testB, all .png files, packaged as photos.tar.gz
    tar -zcvf photos.tar.gz ./*.png
  6. Decompression photos.tar
    tar -xvf photos.tar
  7. Decompression photos.tar.gz
    tar -zxvf photos.tar

note:

  1. -c -x -t parameter in a command can only use one
  2. -f parameter must be the last parameter, such as -cvf, -zxf
  3. In addition -f must last parameter, the other parameters are not distinguished order, acting in such a -cvf and -vcf
  4. 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

Guess you like

Origin www.cnblogs.com/wintest/p/11183713.html