Tar usage Summary

Source: Internet
Author: User

To back up data today, run the tar command.

Compression command:

Tar-zvvf ticket-data-intgration.tar.gz ticket-data-intgration

Compressed but does not contain a folder

Tar -- exclude/home/Q/ticket-data-intgration/log -- exclude/home/Q/ticket-data-intgration/cache-zvvf ticket-data-intgration.tar.gz/home/Q/ticket-Data -intgration

View tar package files

Tar-tzvf ticket-data-intgration.tar.gz

Error:/bin/tar: removing leading '/' from Member names

In Linux, absolute paths are generally not recommended when tar is used to package files. If no parameter is specified during absolute path packaging, tar generates a warning message: "Tar: removing leading '/' from Member names ", in addition, the actual compressed package will convert the absolute path to the relative path. For example:

[email protected] ~ # tar -czvf robin.tar.gz /home/robintar: Removing leading `/‘ from member names/home/robin//home/robin/file1/home/robin/file2/home/robin/file3[email protected] ~ # tar -tzvf robin.tar.gzdrwxr-xr-x robin/root        0 2009-11-10 18:51:31 home/robin/-rw-r--r-- robin/root        0 2009-11-10 18:51:28 home/robin/file1-rw-r--r-- robin/root        0 2009-11-10 18:51:30 home/robin/file2-rw-r--r-- robin/root        0 2009-11-10 18:51:31 home/robin/file3[email protected] ~ #

If we unbind such a compressed package, the current directory (that is, "~" in this example) will be displayed. And then create the "./home/Robin/" directory. For such a compressed package, the decompression method is to use the "-c" parameter to indicate that the extracted directory is the root directory ("/"): tar-xzvf pai.tar.gz-C/

The more convenient method is to use the parameter-P during packaging and unbundling:

[email protected] ~ # tar -czvPf robin.tar.gz /home/robin//home/robin//home/robin/file1/home/robin/file2/home/robin/file3[email protected] ~ # tar tzvf robin.tar.gzdrwxr-xr-x robin/root        0 2009-11-10 18:51:31 /home/robin/-rw-r--r-- robin/root        0 2009-11-10 18:51:28 /home/robin/file1-rw-r--r-- robin/root        0 2009-11-10 18:51:30 /home/robin/file2-rw-r--r-- robin/root        0 2009-11-10 18:51:31 /home/robin/file3[email protected] ~ # tar -xzvPf robin.tar.gz/home/robin//home/robin/file1/home/robin/file2/home/robin/file3[email protected] ~ #

Note: The upper-P Case and position cannot be changed.

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.