4

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?

Eric Carvalho
  • 54,385
Abundance
  • 227

1 Answers1

2

From tar manpage:

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

You should run:

sudo tar cPf - ../Documents | tar xPf -
Eric Carvalho
  • 54,385