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 namesI 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?
11 Answer
From tar manpage:
-P, --absolute-names don't strip leading '/'s from file names
You should run:
sudo tar cPf - ../Documents | tar xPf -