Detailed tar decompression command

Decompression operation:
#tar -zxvf /usr/local/test.tar.gz


tar decompression command details


-c: create a compressed file

-x: decompress
-t: view content
-r: append files to the end of the compressed archive
-u: update the files in the original archive

These five commands are independent, and one of them should be used for compression and decompression. It can be used in conjunction with other commands, but only one of them can be used. The following parameters are optional when compressing or decompressing archives as needed.

-z: with gzip attribute
-j: with bz2 attribute
-Z: with compress attribute
-v: show all processes
-O: unpack file to stdout

The following parameter -f is required

-f: Use the file name, remember, this parameter is the last parameter, only the file name can be followed.

# tar -cf all.tar *.jpg 
This command is to type all .jpg files into a package named all.tar. -c means to generate a new package, -f specifies the file name of the package.

# tar -rf all.tar *.gif 
This command is to add all .gif files to the all.tar package. -r means to add files.

# tar -uf all.tar logo.gif 
This command is to update the logo.gif file in the original tar package all.tar, -u means to update the file.

# tar -tf all.tar 
This command is to list all the files in the all.tar package, -t means to list the files

# tar -xf all.tar 
This command is to unpack all files in the all.tar package, -x means unpack

compression

tar –cvf jpg.tar *.jpg //将目录里所有jpg文件打包成tar.jpg

tar –czf jpg.tar.gz *.jpg   //将目录里所有jpg文件打包成jpg.tar后,并且将其用gzip压缩,生成一  个gzip压缩过的包,命名为jpg.tar.gz

tar –cjf jpg.tar.bz2 *.jpg //将目录里所有jpg文件打包成jpg.tar后,并且将其用bzip2压缩,生成一个bzip2压缩过的包,命名为jpg.tar.bz2

tar –cZf jpg.tar.Z *.jpg   //将目录里所有jpg文件打包成jpg.tar后,并且将其用compress压缩,生成一个umcompress压缩过的包,命名为jpg.tar.Z

rar a jpg.rar *.jpg //rar格式的压缩,需要先下载rar for linux

zip jpg.zip *.jpg //zip格式的压缩,需要先下载zip for linux

解压

tar –xvf file.tar //解压 tar包

tar -xzvf file.tar.gz //解压tar.gz

tar -xjvf file.tar.bz2   //解压 tar.bz2

tar –xZvf file.tar.Z   //解压tar.Z

unrar e file.rar //解压rar

unzip file.zip //解压zip

Summary
  (1), *.tar decompress with tar –xvf
  (2), *.gz decompress with gzip -d or gunzip
  (3), *.tar.gz and *.tgz decompress with tar –xzf
  (4), * .bz2 is decompressed with bzip2 -d or bunzip2
  (5), *.tar.bz2 is decompressed with tar -xjf
  (6), *.Z is decompressed with uncompress
  (7), *.tar.Z is decompressed with tar -xZf
  (8 ), *.rar is decompressed with unrar e
  (9), *.zip is decompressed with unzip

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326395063&siteId=291194637