[LINUX] tar

  

tar

-c: Create compressed file -x: Unzip -t: View content -r: Append file to the end of compressed archive -u: Update file in original archive Br>

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 The command is to solve all the files in the all.tar package, -x is the meaning of unlocking

Compression
tar –cvf jpg.tar *.jpg Package all jpg files in the directory into tar.jpgtar –czf jpg.tar.gz *.jpg After packaging all the jpg files in the directory into jpg.tar, and compressing them with gzip, generate a gzip-compressed package named jpg.tar.gztar –cjf jpg .tar.bz2 *.jpg Package all the jpg files in the directory into jpg.tar and compress them with bzip2 to generate a bzip2 compressed package named jpg.tar.bz2tar –cZf jpg.tar.Z *.jpg Package all the jpg files in the directory into jpg.tar, and compress them with compress to generate a umcompress compressed package named jpg.tar.Zrar a jpg.rar *.jpg rar format compression, Need to download rar for linuxzip jpg.zip *.jpg zip format compression, you need to download zip for linux

first extract
tar –xvf file.tar extract tar package tar -xzvf file.tar.gz extract Tar.gztar -xjvf file.tar.bz2 Unzip tar.bz2tar –xZvf file.tar.Z Unzip tar.Zunrar e file.rar Unzip rarunzip file.zip Unzip zip

Summary
*.tar with tar &ndash ;xvf decompress *.gz decompress gzip -d or gunzip *.tar.gz and *.tgz decompress tar –xzf *.bz2 decompress bzip2 -d or bunzip2 *.tar.bz2 decompress with tar –xjf *.Z Uncompress uncompress *.tar.Z Decompress with tar –xZf *.rar Unzip with unrar *.zip Unzip with unzip

Copyright © Windows knowledge All Rights Reserved