1. Pack all. jpg files into a package named all.tar: tar-CF all.tar *. jpg;-C indicates that a new package is generated, and-F specifies the package file name.
Add all .gif files to the package of all.tar: tar-RF all.tar *. gif;-r indicates adding files.
Update the original logo.gif file in tarbao all.tar: tar-UF all.tar logo.gif;-u indicates the file to be updated.
List all files in the all.tar package: tar-TF all.tar;-T indicates listing files.
Extract all files in the all.tar package: tar-XF all.tar;-X indicates unlocking.
2 tar call Gzip
Gzipis a program developed by gnuorganization. The file ending with .gz is the result of gzip compression. The decompress program relative to gzip is gunzip. Use the-Z parameter in tar to call gzip. The following is an example:
Tar-CZF all.tar.gz *. jpg
Bytes
Tar-xzf all.tar.gz
This command unlocks the generated package.
3 tar call Bzip2
Bzip2is a more powerful compression program. The file ending with .bz2 is the result of Bzip2 compression. The decompress program relative to Bzip2 is bunzip2. Use the-J parameter in tar to call gzip. The following is an example:
Tar-CJF all.tar.bz2 *. jpg
Bytes
Tar-xjf all.tar.bz2
This command unlocks the generated package.
4 tar call Compress
Compress is also a compression program, but it seems that there are not as many people using compress as gzip and Bzip2 .. The file ending with Z is the result of Bzip2 compression. The decompress program relative to compress is uncompress. Use the-Z parameter in tar to call gzip. The following is an example:
Tar-CZF all.tar. z *. jpg
Forbidden. Z
Tar-xzf all.tar. Z
This command is used to unbind the generated package.
5. Decompression Summary
For the file ending with .tar: tar-XF all.tar
For the file ending with .gz: gzip-D all.gz gunzip all.gz
For files ending with .tgzor .tar.gz: tar-xzf all.tar.gz tar-xzf all. tgz
For the file ending with .bz2: Bzip2-D all.bz2 bunzip2 all.bz2
For the file ending with tar.bz2: tar-xjf all.tar.bz2
For uncompress all. Z files ending with. Z
For the file ending with .tar. Z: tar-xzf all.tar. Z
For. Zip: compression: Zip all.zip *. jpg/decompress: unzip all.zip
For .rar, you need to install RAR for Linux. For compression: rar a all * .jpg, this program will automatically append the .rar extension name to the package name. Unrar e all.rar
Tar is a common and important command in UNIX. The tar command Copies files on the disk to the file media (for example, from a floppy disk to a hard disk or from a hard disk to a floppy disk ), or recover the recorded files from the archive media to files on the disk. In case of an error, the T ar command does not provide any restoration operations.
Tar command format:
# Tar-CVF (or xvf) + file name + device
C-> Local to other devices
X-> other devices to the local device
R-> is to add a file (such as a t.txt file ).
A tar file (or folder) uses the CVF parameter;
Unbind the tar file and use the xvf parameter.
For example:
Run the following command to tar the file "/home/test" to/ANW and tar it into "exe.tar:
# Tar-CVF/ANW/exe.tar/home/test
To unbind the tar file, run the following command:
# Tar-xvf/ANW/exe.tar will remove exe.tar to the path specified during compression.
The extension of the tar command to generate a file can be arbitrary. For example, the file generated by the test file can be test. A and test. B extension test.tar.