LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   Strip leading dot in filepaths (in tar archive) (https://www.linuxquestions.org/questions/debian-26/strip-leading-dot-in-filepaths-in-tar-archive-312757/)

EcceVery 04-13-2005 08:06 AM

Strip leading dot in filepaths (in tar archive)
 
I'm putting together a archive containing some programs and symlinks in /etc/rc2.d (for debian systems). When the file is extracted I want some of the files to be placed in /etc,some in /etc/init.d and so on. I have created that exact path in another directory and tar'ed the files, but when I list the contets I get aleading dot in the beginning of all file paths.

How do I strip just the leading dot, leaving the rest of the path untouched in the archive?

mjrich 04-13-2005 04:06 PM

What command did you use to create the tar archive ?

mj

thegeekster 04-13-2005 07:47 PM

There are different approaches you can take.................You probably used the 'find' command for adding the files to tar, or used "tar -cf xxxx.tar ."........

Normally, 'tar' will strip the leading forward slash (/) if given an absolute path, however if you used 'find' while in the directory containing the files and directories you are trying to store, and using this syntax "find ." (or "find" by itself), it will add "./" at the beginning of each path............To avoid this, you must enter the name of the directory to find to get a full path, such as "find /etc/init.d /etc/rc2.d"..............When fed to tar, tar will automatically strip the leading / from the path, thus making it a relative path instead of an absolute path, unless you add the switch to keep it as an absolute path (tar -P, or tar --absolute-names).......

If you used "tar -cf xxx.tar ." this will also create files with a leading "./"...............Instead, you must again supply the name of the directory here, such as "tar -cf xxx.tar /etc/init.d /etc/rc2.d", to avoid the "./" at the beginning

HTH :)


All times are GMT -5. The time now is 06:28 PM.