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/out box/001/co n-cust.d
/tmp# tar xf 001.tar puts the file in:
/wdsfiles/boss/mailbox/out box/001/co n-cust.d
Linux:
tar tvf 001.tar shows:
-rw-rw-rw- 2123/1 3956 Mar 26 19:15 2010 /wdsfiles/boss/mailbox/out box/001/co n-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/00 1/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/00 1/con-cust .d
tar tvf 001.tar shows:
-rw-rw-rw- 2123/1 3956 Mar 26 19:15 2010 /wdsfiles/boss/mailbox/out
/tmp# tar xf 001.tar puts the file in:
/wdsfiles/boss/mailbox/out
Linux:
tar tvf 001.tar shows:
-rw-rw-rw- 2123/1 3956 Mar 26 19:15 2010 /wdsfiles/boss/mailbox/out
/tmp# tar xf /wdsfiles/boss/mailbox/001
tar: Removing leading `/' from member names
and then puts the file in:
/tmp/wdsfiles/boss/mailbox
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
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/00 1/con-cust .d
tar xvfP /tmp/wdsfiles/boss/mailbox
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Exactly what I needed! Thanks.