Tar remove the leading '/' from member names

I got an error when I add> /dev/null to the tar command, does anyone know what is happening in the second example?

OK:

  tar -cvf $kname /var/www 

badly:

  tar -cvf $kname /var/www > /dev/null error:tar: Removing leading `/' from member names 
+7
linux tar
source share
3 answers

The "good" version also displays the same message that you just missed.

If you do not like the behavior, find the "leader" in manual mode. First strike:

 -P, --absolute-names don't strip leading '/ from file names 
+9
source share

This is because your file ( $kname ) has a leading / .

To fix this, you can specify -C to change the directory, and not to specify the full path to the archive file.

+5
source share

It is best to leave your files without a β€œ/” in the backup and just ignore the error message. Tar does this as a precaution, because if you unzip the file, it will automatically put the files back into the source directory. This can be dangerous, and most people want to avoid it. Personally, I would be pleased with the fact that he deleted '/', and then your recovery will be a relative, not an absolute directory. Then you can manually move the files to the desired location or to another location. Just post it so people know and don't accidentally replace their source files.

0
source share

All Articles