PDA

View Full Version : TAR command warning



oweri
May 21st, 2011, 04:55 AM
May I know what is wrong in the following TAR command?
It works, but generate a warning...

> tar -cpzvf /etc/a000/backup.tar.gz /etc/r000
tar: Removing leading `/' from member names

Telengard C64
May 21st, 2011, 05:19 AM
May I know what is wrong in the following TAR command?
It works, but generate a warning...

> tar -cpzvf /etc/a000/backup.tar.gz /etc/r000
tar: Removing leading `/' from member names

I don't see anything wrong with the command. That warning is just that, a warning. The / prefix is not recorded in your archive, I think to avoid possible trouble later.

That's okay, because you should change the working directory prior to extracting anyway. If you really, really want your archived files extracted in the root folder, then cd / before you tar -xzvf.

HTH

matt_symes
May 21st, 2011, 12:59 PM
Hi


May I know what is wrong in the following TAR command?
It works, but generate a warning...

> tar -cpzvf /etc/a000/backup.tar.gz /etc/r000
tar: Removing leading `/' from member names

This is no issue at all. It is removing the / to create a relative path in the archive and not an absolute path. That way when you unpack the archive it will appear under your current working directory and not under the root directory /.

This is generally what you want and it is also safer as you are less lightly to overwrite important files.

If you want to get rid of the warning you can use the -C flag to change to the root directory.

tar -cpvf /etc/a000/backup.tar.gz -C / /etc/r000

IIRC, That should get rid of it.

Kind regards