Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tar Question - Remove Leading "/" From Member Names

Status
Not open for further replies.

cmayo

MIS
Apr 23, 2001
159
US
Hi All,

My server is running a GNU version of tar, and I have a cron job running a shell script to perform a daily backup of a directory with this command:

Code:
/bin/tar cvfz /home/tandem/backups/files.tar /home/tandem/

The shell script itself resides inside /home/tandem/backups/.

Upon executing, tar emits the message:

Code:
/bin/tar: Removing leading `/' from member names

Since I'm giving tar an absolute path, this is exactly what I want tar to do... I want tar to remove that leading '/' so that my archive path will be a relative path, home/tandem/backups/files.tar.

My concern is this: Other versions of tar I've used in the past don't automatically remove that leading '/' from member names and I want to make sure that if my code moves to another platform with another version of tar, that I never write an archive with that leading '/' in front of the member names... I've done that before and had critical directories under '/' overwritten when the archive was extracted.

So... is there a mostly-universal switch I can provide tar that'll cause any version to remove the leading '/' from member names? If not, how can I specify the relative path, considering that my backups need to begin in the directory just above the directory containing my backup shell script?

Thanks in advance for any tips!
 
man cd

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
To elaborate a bit on PHV's excellent reply...

No matter where in your dir-structure a script is physically located, at runtime, the script can cd into any dir it chooses, so that it can access directories relative to that chosen dir.


HTH,

p5wizard
 
Doh! Guess I had my head too far up my... um.. code to see the obvious. PHV was correct, of course. I added the cd to my shell script and all is well.

Thanks guys!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top