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