I am testing out the functionality of tar by compressing and extracting directories as follows:

cd test
mkdir Documents
mkdir foo
cd foo  
sudo tar cf - ../Documents | tar xf -  

The last command gives me the following error:

tar: Removing leading `../' from member names

I know that we need to force tar to take in absolute pathnames but this is a relative one. Why isn't tar accepting this argument?

From tar manpage:

-P, --absolute-names
      don't strip leading '/'s from file names

You should run:

sudo tar cPf - ../Documents | tar xPf -

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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