Untar to different location

I have a tar file where the files have been tar'd along with the location of the file i.e

/opt/abc/file.txt
/opt/abc/file2.txt

I am trying to untar this file on a different server where /opt/abc does not exist.

How do I untar these files without the tar trying to create the structure /opt/abc??

I really need to do this without the /opt/abc location being created on my server.

You could use pax:
pax -r -s '=^/opt/abc=/tmp=' < tarfile

1 Like

Or maybe chroot

You could install GNU tar from www.sunfreeware.com as that strips leading slashes form pathnames by default.