Today's 'tar' tip

Use pax command to bypass absolute paths . . .

rule

CODfish
by Tom Parker


Contents

Search

Index

Home

Subscribe

ConsultWeb

SCD

Ever have trouble untarring a tar file because the file names have absolute rather than relative pathnames? If so, you might be able to use the pax command to bypass the absolute paths.

For example, suppose you have a tar file whose directory looks like this:

  % tar tvf my.tar
  rw-------  1829  0  1269 Jun  8 19:21 1994 /abs/dir/a
  rw-------  1829  0  2243 Jun  9 16:53 1994 /abs/dir/b
  rw-------  1829  0  2222 Jun  9 16:53 1994 /abs/dir/c
  rw-------  1829  0  3827 Jun  9 16:53 1994 /abs/dir/d

If you try to untar this (typically with tar xvf my.tar), it will probably complain that it can't create the directory /abs/dir. Now, if you have "root" privileges you can probably plow ahead, but for the rest of us, this is a big problem.

Fortunately, the pax command can save the day -- by allowing you to change those absolute pathnames while it also untars the file. For example:

   % pax -rvf my.tar -s,/abs/dir/,,

will basically remove the /abs/dir/ part of each filename, resulting in untarred files by the names of a, b, c, and d, in this case.

The -s option of pax allows you to change the names of the tarred files by using string substitution, as in the ed command.

The pax command is available on all SCD systems. For more information, type man pax.

rule

Contents || Search || Index || Home || Subscribe || ConsultWeb || SCD