Link to home
Start Free TrialLog in
Avatar of Shannon Adams
Shannon Adams

asked on

Unix/Linux tar - absolute path & relative path confusion

Unix:
tar tvf 001.tar shows:
-rw-rw-rw- 2123/1     3956 Mar 26 19:15 2010 /wdsfiles/boss/mailbox/outbox/001/con-cust.d

/tmp# tar xf 001.tar puts the file in:
/wdsfiles/boss/mailbox/outbox/001/con-cust.d

Linux:
tar tvf 001.tar shows:
-rw-rw-rw- 2123/1     3956 Mar 26 19:15 2010 /wdsfiles/boss/mailbox/outbox/001/con-cust.

/tmp# tar xf /wdsfiles/boss/mailbox/001.tar displays:
tar: Removing leading `/' from member names

and then puts the file in:
/tmp/wdsfiles/boss/mailbox/outbox/001/con-cust.d

First, why am I getting the "Removing leading `/' from member names" error when extracting the file in Linux?
Secondly, what is the command in Linux to extract the tar file into the absolute path of:
/tmp/wdsfiles/boss/mailbox/outbox/001/con-cust.d
Avatar of Superdave
Superdave
Flag of United States of America image

It's a safety thing, because somebody could make a tar archive that could overwrite any file on your system by using an absolute path name.  So GNU's tar changed the way it works.  Use tar xvPf to get the absolute path.
use this,

tar xvfP /tmp/wdsfiles/boss/mailbox/outbox/001/con-cust.d
Avatar of Shannon Adams
Shannon Adams

ASKER

tar xvfP  is what I was looking for, thanks.  However, I am confused about actually tarring files/directories in Linux vs. Solaris.

In Solaris, if you wanted to tar up a file(s), or a directory and store as an absolute path, you could do this:
tar cf - /tmp/sra/* > /tmp/test.tar

To extract contents of test.tar back into the same path (/tmp/sra):
tar xf /tmp/sra.tar

These commands will not work in Linux.  Can you provide the command to actually tar up the directory /tmp/sra and store in /tmp/test.tar using absolute pathes?  Therefore, when I use "tar xvPf /tmp/test.tar", it should extract the contents back into /tmp/sra.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Superdave
Superdave
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Exactly what I needed!  Thanks.