How to use the Unix tar command with an implicit filepath

tar

I am using the tar -xvf command and it is taking the explicit path. However, the path is full.
Example:

tar -xvf 13.2.tar

It is taking the path of /mnt folder. The / folder is full.

How can I tar the file with the implicit path?

Best Answer

Usually tar needs the --absolute-names or --absolute-paths option to retain the root '/' part while creating an archive. Even if you force it in that way, the extract skips the leading '/' too.


However, if you have an archive with the leading '/' and you tar does not skip it while extracting, NoahD's answer should work in this form,

pax -r -s ',/mnt,/new/path,' -v -f 13.2.tar

I think pax does not handle compressed files, so you would need to pipe after decompress into pax.
That would go like this (assuming you have a gzipped archive)

gunzip -c 13.2.tar.gz | pax -r -s ',/mnt,/new/path,' -v

I found this wiki page on Google just now.

Related Question