A detailed description of the TAR packaging tool

Source: Internet
Author: User

Tar itself is a packaging tool that can package a directory into a file, which has the advantage of consolidating all the files into a single large file, making it easy to copy or move.

Syntax: tar [-ZJXCVFPP] filename

The TAR catalog has several options:

-Z: Simultaneously with gzip compression

-j: Simultaneous compression with bzip2

-X: Unpacking or decompressing

-T: View the files inside the tar package

-C: Build a tar package or zip file package

-V: Visualize

-F: followed by the file name, compressed with "-F file name", meaning that the compressed file name is filename, decompression with "-f filename", meaning to extract filename, in order to avoid error recognition, multiple options and use, put F in the back.

-P: Use the properties of the original file, what properties to compress before compressing what attributes (not commonly used)

-P: Absolute path can be used (not commonly used)

--exclude filename: Do not include the filename file when packaging or compressing (infrequently used)

[[email protected] test]# mkdir test111[[email protected] test]# touch Test111/test2.txt[[email protected] test]# echo "ni Hao ">! $echo" Nihao ">test111/test2.txt[[email protected] test]# lstest111 test.txt.xz[[email protected] test]# TAR-CVF Test111.tar test111test111/test111/test2.txt[[email protected] test]# lstest111 Test111.tar test.txt.xz

You can do this without the -V or no visualization.

[Email protected] test]# rm-f test111.tar[[email protected] test]# tar-cf Test.tar test111 test.txt.xz[[email protected ] test]# lstest111 Test.tar test.txt.xz

Unpack the package:

[[email protected] test]# RM-RF test111[[email protected] test]# Lstest.tar test.txt.xz[[email protected] test]# TAR-XV F TEST.TARTEST111/TEST111/TEST2.TXTTEST.TXT.XZ

--exclude using:

[Email protected] test]# TAR-CVF test111.tar--exclude test3.txt test111test111/test111/test2.txttest111/ Test4.txttest111/test5/[[email protected] test]# rm-f test111.tar[[email protected] test]# TAR-CVF Test111.tar--exclud E test5 Test111test111/test111/test2.txttest111/test3.txttest111/test4.txt

Tar package and compress and use

The tar command supports gzip compression and BZIP2 compression as well as XZ.

[Email protected] test]# TAR-CZVF test111.tar.gz test111test111/test111/test2.txttest111/test3.txttest111/ Test4.txttest111/test5/[[email protected] test]# lstest111 test111.tar test111.tar.gz Test.tar test.txt.xz

The main function here is the-Z option, which means using gzip compression. "-TF" can view a list of files for packages or compressed packages:

[Email protected] test]# TAR-TF test111.tar.gztest111/test111/test2.txttest111/test3.txttest111/test4.txttest111/ test5/

"-ZXVF" is used to decompress the. tar.gz Compressed Package

[Email protected] test]# RM-RF test111[[email protected] test]# Lstest111.tar test111.tar.gz Test.tar test.txt.xz[[em AIL protected] test]# TAR-ZXVF test111.tar.gztest111/test111/test2.txttest111/test3.txttest111/test4.txttest111/ Test5/[[email protected] test]# lstest111 test111.tar test111.tar.gz Test.tar test.txt.xz

The bzip2 compression package uses the "-CJVF" option to implement the

[Email protected] test]# TAR-CJVF test111.tar.bz2 test111test111/test111/test2.txttest111/test3.txttest111/ Test4.txttest111/test5/[[email protected] test]# lstest111 test111.tar test111.tar.bz2 test111.tar.gz Test.tar test.t Xt.xz[[email protected] test]# TAR-TF test111.tar.bz2test111/test111/test2.txttest111/test3.txttest111/ test4.txttest111/test5/

unzip with "-JXVF"

[Email protected] test]# RM-RF test111[[email protected] test]# TAR-JXVF test111.tar.bz2test111/test111/  Test2.txttest111/test3.txttest111/test4.txttest111/test5/[[email protected] test]# lstest111 Test111.tar test111.tar.bz2 test111.tar.gz Test.tar Test.txt.xz

Packaging uses XZ as the form of compression and decompression:

[Email protected] test]# TAR-CJVF test111.tar.xz test111test111/test111/test2.txttest111/test3.txttest111/ Test4.txttest111/test5/[[email protected] test]# lstest111 test111.tar.bz2 test111.tar.xz Test.txt.xztest111.tar t est111.tar.gz Test.tar[[email protected] test]# rm-rf test111[[email protected] test]# TAR-JXVF test111.tar.xztest111/      Test111/test2.txttest111/test3.txttest111/test4.txttest111/test5/[[email protected] test]# lstest111 test111.tar.bz2 test111.tar.xz Test.txt.xztest111.tar test111.tar.gz Test.tar



This article is from the "Learn Notes for students" blog, please make sure to keep this source http://sanyisheng.blog.51cto.com/11154168/1795715

A detailed description of the TAR packaging tool

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.