0

I use tar about once every 10 years and made a backup off a failed inaccessible drive that luckily worked fine. Except that instead of backing up just /home (and everything under it), it backed up /path/to/home.

So for example, when I just extract with a simple tar xzvf mytarfile.tar.gz in my home directory it creates a sub dir called path/ and in that a to/ and finally the home/ that I really want to appear ../../../ above.

So again, what I'm getting is:

/home/myhomedir/path/to/home/allthefilesIwant

And what I WANT is:

/home/myhomedir/allthefilesIwant

Is there any way to get tar to strip this extraneous path that's prepended to the home dir content I want to restore?

0

Add --strip-components=NUMBER to your tar command.

In your example (/home/myhomedir/path/to/home/allthefilesIwant), you should set NUMBER to 3.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.