Linux tar.gz, tar, zip, etc. decompress, compress the command

  

tar

-c: create a compressed file -x: decompress -t: view the content -r: append to the end of the compressed archive File -u: Update the files in the original archive

These five are independent commands. One of them is used for compression and decompression. It can be used with other commands but only one of them can be used. The following parameters are optional when compressing or decompressing files as needed.

-z: with gzip attribute -j: with bz2 attribute -Z: with compress attribute -v: show all procedures -O: unpack the file to standard output

The 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 make all .jpg files into a package called all.tar. -c indicates that a new package is generated, and -f specifies the file name of the package. # tar -rf all.tar *.gif This command adds all .gif files to the all.tar package. -r means to add a file. # tar -uf all.tar logo.gif This command updates the logo.gif file in the original tarball all.tar, and -u means the update file. # tar -tf all.tar This command lists all the files in the all.tar package, -t is the meaning of the listed files # tar -xf all.tar This command solves all the files in the all.tar package. -x is the meaning of unlocking Compress tar –cvf jpg.tar *.jpg //Pack all jpg files in the directory into tar.jpg tar –czf jpg.tar.gz *.jpg //All jpg in the directory The file is packaged into jpg.tar, and it is compressed with gzip to generate a gzip-compressed package named jpg.tar.gz tar –cjf jpg.tar.bz2 *.jpg //All jpg files in the directory After packaging it into jpg.tar, and compressing it with bzip2, generate a bzip2 compressed package named jpg.tar.bz2 tar –cZf jpg.tar.Z *.jpg //Pack all the jpg files in the directory After jpg.tar, and compress it with compress, generate a umcompress compressed package, named jpg.tar.Z rar a jpg.rar *.jpg //rar format compression, you need to download rar for linux zip first Jpg.zip *.jpg //zip format compression, you need to download zip for linux

unzip tar –xvf file.tar //decompress tar package tar -xzvf file.tar.gz //solution Tar.gz tar -xjvf file.tar.bz2 //Unzip tar.bz2 tar –xZvf file.tar.Z //Unzip tar.Z unrar e file.rar //Unzip rar unzip file.zip //Unzip zip< Br>

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 use bzip2 -d or bunzip2 decompression 5, *.tar.bz2 decompress with tar –xjf 6, *.Z decompress with uncompress 7, *.tar.Z decompress with tar –xZf 8, *.rar with unrar eUnzip 9, *.zip Unzip with unzip

Copyright © Windows knowledge All Rights Reserved