extracting tar files with absolute pathnames relatively

Mike Spitzer mjs at mentor.cc.purdue.edu
Fri Apr 21 11:30:23 AEST 1989


In article <1501 at cfa205.cfa250.harvard.edu> todd at cfa250.harvard.edu (Todd Karakashian) writes:
>I am in posession of tapes containing tarfiles with absolute
>pathnames.  What I would like to do is to extract these files into a
>different tree structure than they were tarred from.  Thus, the
>tarfile /usr/foo/file should go into the disk pathname /temp/file.  I
>have been unable to find a way to do this -- does anyone know how?
>
>I am running SunOS 3.5.  I apologize if this is too simple a question.

Without modifying tar, the easiest was to accomplish this is to use
chroot.  Lucky for you, SunOS (at least 4.0... I think that 3.? had
this too) has a chroot(8) command. Try something like this (you'll
have to be root):

	mkdir /tmp/newroot
	cp tarfile /tmp/newroot
	chroot /tmp/newroot tar xf /tarfile

If you don't have the chroot program, it's pretty simple to write.
See the chroot(2) man page for more information.

--
Michael J. Spitzer		Purdue University Computing Center
mjs at mentor.cc.purdue.edu	pur-ee!mentor.cc.purdue.edu!mjs



More information about the Comp.unix.questions mailing list