http://www.perlmonks.org?node_id=812372


in reply to Archive:Tar appears to store absolute pathnames as relative pathnames

yea this is what also tar does.
i.e. if you compress /home/users/you/dir/
you will have home/users/you/dir

unpacking it to / is the receiver choice. you can't force him to unpack on /

UPDATE: ok, it looks like you can, on tar you must use -P, and it won't unpack to / if you don't also use -P when unpack

Replies are listed 'Best First'.
Re^2: Archive:Tar appears to store absolute pathnames as relative pathnames
by Bloodnok (Vicar) on Dec 11, 2009 at 13:30 UTC
    ...if you compress /home/users/you/dir/ you will have home/users/you/dir

    Obviously it's a feature of the compression that I'd not noticed 'til now - a gotcha I'll be sure to remember from here on in...

    <c> ...you can't force him to unpack on /

    ..which, IMO, just goes to show that the use of compressed tar(1) files is not the way to go from the POV of software delivery where delivery of absolute files is frequently an immutable requirement.

    A user level that continues to overstate my experience :-))
Re^2: Archive:Tar appears to store absolute pathnames as relative pathnames
by Anonymous Monk on Apr 20, 2011 at 14:05 UTC
    You can also compress using the -C option, to change to that directory, and then you will have relatives paths. for example: /home/users/you/dir I can compress using: tar -czf example.tar.gz -C /home/users/you dir And you will get a tar with the directory dir.