Tar.gz

Does anyone know if it is possible to decompress a tar file into a
specified directory? When i decompress the tar file now using tar -xvf
filename the files contained in the tar file decompress to their root
directory.

Sergei Borodinski <sergei@engr.mun.ca> wrote:

Does anyone know if it is possible to decompress a tar file into a
specified directory? When i decompress the tar file now using tar -xvf
filename the files contained in the tar file decompress to their root
directory.

Try pax -rov -f archive.pax -s ,^/,/tmp/own_dir,

tar is a link to pax

Michael

OR… just put the tar file in the directory that you want the files in
and then untar it using the syntax you mentioned.

In article <9tb9pe$65r$1@mbs-software.de>, “michael.huebbers”
<michael.huebbers@mbs-software.de> wrote:

Sergei Borodinski <> sergei@engr.mun.ca> > wrote:
Does anyone know if it is possible to decompress a tar file into a
specified directory? When i decompress the tar file now using tar -xvf
filename the files contained in the tar file decompress to their root
directory.

Try pax -rov -f archive.pax -s ,^/,/tmp/own_dir,

tar is a link to pax

Michael

Sergei Borodinski <sergei@engr.mun.ca> wrote:

Does anyone know if it is possible to decompress a tar file into a
specified directory? When i decompress the tar file now using tar -xvf
filename the files contained in the tar file decompress to their root
directory.

Depends on how the tar file made. If it is created with relative path
(tar cvf - ./something), then you can just “cd the_dir; tar xvf file”

Now if the tar created with absolute path (tar cvf - /fullpath/something),
then you need to do sth like “on -r /mydir /bin/tar file”.

-xtang

Let me try to explain. It isn’t as difficult to understand as I think these
posts make it sound.

First, when someone builds a tarball, the polite thing to do is to save
relative directories. You seems to have a tarball that was saved with
absolute directories. But, you can still unarchive to the directory that
you want. It’s just a little more work.

Example 1: relative directories

If I am in a directory called mydir:
cd ~/mydir
and I wanted to archive everything in a project directory (proj1), you could
type:
pax -w proj1 | gzip > tarball.tgz

Then someone else can install that project whereever they want:
cd /some/really/long/path/name
gunzip < tarball.tgz | pax -r
this will put those files into:
/some/really/long/path/name/proj1

Example 2: Bad, rude, pain in the a__

If you type:
pax -w /home/bill/proj1 | gzip > tarball.tgz
All of the files stored in this archive are stored with absolute pathnames.
So no matter what directory someone is in when they:
gunzip < tarball.tgz | pax -r
they will go into /home/bill/proj1
If there was no /home/bill pax will create one for you. Worse yet, if there
IS a /home/bill on this system pax will put these files there. Even if bill
HAD a proj1 and he didn’t want YOU overwriting them. Of course permissions
will prevale!

Solution:

Step 1: I always:
gunzip < tarball.tgz | pax -v
This does NOT do a restore. But it DOES show you WHAT is in the archive and
weather the pathnames are relative or absolute. If they are relative, good
for you. Just cd into the directory where you wnt these files and:
gunzip < tarball.tgz | pax -r

If the do-do that created this archive saved it with absolute pathnames then
you can over rule their parent directory with your choice. pax has a ‘-s’
option. -s says substitude a source directory to a target directory. The
character immediately after the -s becomes a delimiter. In this example I
wil use comma ‘,’ as a delimiter. You may use any character you want that
doesn’t otherwise comflict with what you need to type.
gunzip < tarball.tgz | pax -r -s,/home/bill/proj1,/Big_Project,
So now everything that started ou in /home/bill/proj1 will be restored into
/Big_Project.

Other useful trivia:

pax and tar are the same utility. Each one has different default options.
Pax and tar will merge several files into one file OR extract several files
from one file. But, they don’t compress or decompress them. The
gzip/gunzip utility does compress or decompress files (guess which is
which). gzip and gunzip are compatable with Windows. Formally, most UNIX
systems would have used freeze and melt to compress and decompress files.
But this format is NOT compatable with Windows. So gzip and gunzip have
taken over in popularity. freeze and melt are the same utility.

Some common extensions:
…pax or .tar represent an archive build with pax or tar.
…zip, .gz (and others) represent a file compressed with gzip.
…tar.zip, .tar.gz, .tgz or .tz represent an archive built with par or tar
and compressed with gzip.
…F represents a file compressed with freeze
…pax.F represents an archive built with pax or tar and compressed with
freeze.

\

Bill Caroselli – 1(530) 510-7292
Q-TPS Consulting
QTPS@EarthLink.net


“Xiaodan Tang” <xtang@qnx.com> wrote in message
news:9tce04$16t$1@nntp.qnx.com

Sergei Borodinski <> sergei@engr.mun.ca> > wrote:
Does anyone know if it is possible to decompress a tar file into a
specified directory? When i decompress the tar file now using tar -xvf
filename the files contained in the tar file decompress to their root
directory.

Depends on how the tar file made. If it is created with relative path
(tar cvf - ./something), then you can just “cd the_dir; tar xvf file”

Now if the tar created with absolute path (tar cvf - /fullpath/something),
then you need to do sth like “on -r /mydir /bin/tar file”.

-xtang

Thanks Bill, I think your explanation is great!!.


Bill Caroselli <qtps@earthlink.net> escribió en el mensaje de noticias
9tcudv$r0o$1@inn.qnx.com

Let me try to explain. It isn’t as difficult to understand as I think
these
posts make it sound.

First, when someone builds a tarball, the polite thing to do is to save
relative directories. You seems to have a tarball that was saved with
absolute directories. But, you can still unarchive to the directory that
you want. It’s just a little more work.

Example 1: relative directories

If I am in a directory called mydir:
cd ~/mydir
and I wanted to archive everything in a project directory (proj1), you
could
type:
pax -w proj1 | gzip > tarball.tgz

Then someone else can install that project whereever they want:
cd /some/really/long/path/name
gunzip < tarball.tgz | pax -r
this will put those files into:
/some/really/long/path/name/proj1

Example 2: Bad, rude, pain in the a__

If you type:
pax -w /home/bill/proj1 | gzip > tarball.tgz
All of the files stored in this archive are stored with absolute
pathnames.
So no matter what directory someone is in when they:
gunzip < tarball.tgz | pax -r
they will go into /home/bill/proj1
If there was no /home/bill pax will create one for you. Worse yet, if
there
IS a /home/bill on this system pax will put these files there. Even if
bill
HAD a proj1 and he didn’t want YOU overwriting them. Of course
permissions
will prevale!

Solution:

Step 1: I always:
gunzip < tarball.tgz | pax -v
This does NOT do a restore. But it DOES show you WHAT is in the archive
and
weather the pathnames are relative or absolute. If they are relative,
good
for you. Just cd into the directory where you wnt these files and:
gunzip < tarball.tgz | pax -r

If the do-do that created this archive saved it with absolute pathnames
then
you can over rule their parent directory with your choice. pax has a ‘-s’
option. -s says substitude a source directory to a target directory. The
character immediately after the -s becomes a delimiter. In this example I
wil use comma ‘,’ as a delimiter. You may use any character you want that
doesn’t otherwise comflict with what you need to type.
gunzip < tarball.tgz | pax -r -s,/home/bill/proj1,/Big_Project,
So now everything that started ou in /home/bill/proj1 will be restored
into
/Big_Project.

Other useful trivia:

pax and tar are the same utility. Each one has different default options.
Pax and tar will merge several files into one file OR extract several
files
from one file. But, they don’t compress or decompress them. The
gzip/gunzip utility does compress or decompress files (guess which is
which). gzip and gunzip are compatable with Windows. Formally, most UNIX
systems would have used freeze and melt to compress and decompress files.
But this format is NOT compatable with Windows. So gzip and gunzip have
taken over in popularity. freeze and melt are the same utility.

Some common extensions:
.pax or .tar represent an archive build with pax or tar.
.zip, .gz (and others) represent a file compressed with gzip.
.tar.zip, .tar.gz, .tgz or .tz represent an archive built with par or tar
and compressed with gzip.
.F represents a file compressed with freeze
.pax.F represents an archive built with pax or tar and compressed with
freeze.

\

Bill Caroselli – 1(530) 510-7292
Q-TPS Consulting
QTPS@EarthLink.net


“Xiaodan Tang” <> xtang@qnx.com> > wrote in message
news:9tce04$16t$> 1@nntp.qnx.com> …
Sergei Borodinski <> sergei@engr.mun.ca> > wrote:
Does anyone know if it is possible to decompress a tar file into a
specified directory? When i decompress the tar file now using
tar -xvf
filename the files contained in the tar file decompress to their root
directory.

Depends on how the tar file made. If it is created with relative path
(tar cvf - ./something), then you can just “cd the_dir; tar xvf file”

Now if the tar created with absolute path (tar cvf -
/fullpath/something),
then you need to do sth like “on -r /mydir /bin/tar file”.

-xtang