I used it myself before, but I don't need it for a long time. Recently used, it has been found that it cannot be used correctly, so this time record it for later viewing.
The tar command is a packaging command for files (folders) in Linux. Packaging means that multiple files (folders) are made up of a collection. In Linux, only one file can be compressed. To Compress multiple files, you must package them first.
Tar uses the following options:
-C (create): Create a new archive.
-F: The file name followed by the archive.
-T: displays the list of files included in the TAR file.
-V (verbose)-displays detailed archived information
-X (extract)-extracts files from the archive.
-Z: Use gzip to decompress the tar file.
-J-use Bzip2 to compress the tar file.
1. Use tar to package files
Syntax tar-CVF tarname srcname:
Eg: tar-CVF test.tar./Trac-0.12
Enclose the trac-0.12file folder in the preceding directory in the test.tar folder.
In the past, only tar-CVF test.tar was used. The following error is reported :"Tar: exercise caution when rejecting the creation of an empty archive file. In this case, tar does not create an empty tar file.
2. Compress the packaged files
Gzip test.tar
Compress test.tarand the compressed file name is test.tar.gz.
The preceding compressed package can be implemented using a tar command.
Command: tar-CZF test1.tar.gz./Trac-0.12
I always thought it was tar-CF tarname, srcname, and tar-ZF tarname. After packaging with the tar command, Compress With the tar-Z option. It's wrong to try for half a day. It can only be tar-CZF tarname or tar-cfTarname srcname. gzip tarname
3. Extract A. T file.Ar.gz compressed package
Gzip-D (decompress) test.tar.gz
Decompress test.tar.gzto test.tar.
4.unpack test.tar
Tar-XF test.tar
You can use tar to implement the above 3, 4 commands.
Tar-xzf test.tar.gz