Tar:removing leading '/' from member names

Source: Internet
Author: User

Tar:removing leading '/' from Member names+2 Category: Web server Tags: tar 3,910 people browse

This is not a mistake, but a warning, for the simple reason that you are packing an absolute path with tar, to avoid this warning message, in the execution of tar

First, CD to the path where you want to package the files.

The following article explains in detail why, has written quite well, I do not re-build the wheel here, take doctrine a bit ~

*************************************************

It should be clear that theabsolute path is not generally recommended when you use tar to package files in a *nix system.

It is often necessary to use an absolute path for packaging when replicating synchronously on two machines with similar environments. When you use an absolute path to package, Tar generates a warning message if you do not specify the appropriate parameters:

"tar:removing leading '/' from member names"

and the actual resulting compression package will convert the absolute path to a relative path.

Like what:

/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 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] ~ #

Such a compressed package, if we go back to untie, will be the current directory (that is, "~" in this example) to create a new "./home/robin/" Level two directory. For such a compressed package, the decompression method is to use the parameter "-C" refers to the extracted directory as the root directory ("/"):

TAR-XZVF robin.tar.gz-c/

A more reliable approach is to use the parameter- pwhen packing and unpacking:

[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] ~ #

Xiao Bin

Original link: http://xiaobin.net/200911/tar-removing-leading-slash-from-member-name/

Tar:removing leading '/' from member names

Related Article

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.