Click to See Complete Forum and Search --> : ? about gtar in my bash script


gamblor01
06-23-2004, 11:06 AM
So I'm new to shell scripts and I don't think I've ever tarred anything before. But I have a directory, let's say /foo with a bunch of directories that I want to tar as backups. So I did the following:

for i in /foo/*
do
gtar -czf $i.tar.gz $i
done

and let it go. It seems to be making .tar.gz files from all the directories, but it's giving me this output which is strange because it didn't happen when I just tried a single tar by itself such as:

gtar -czf bar.tar.gz bar/

When I do a single tar at a time I don't get this output. But when I do it with my loop like I described first I'm getting this output on the command line:

gtar: Removing leading '/' from absolute path names in the archive
gtar: Removing leading '/' from absolute links

with each new tar.gz file that it's creating. Should I be worried about this or is this just a normal occurence?

serz
06-23-2004, 11:55 AM
You shouldn't worry about it, it's fine.

gamblor01
06-23-2004, 12:20 PM
Ok cool. Since no one had responded too soon and I wanted to get that done, I just went ahead and typed out the commands into a script and ran the script. Copy/pase was my friend! It worked and didn't give me that output about the leading '/' so I was happy.

Just for future reference though, what exactly does that mean?

bwkaz
06-23-2004, 06:39 PM
By default, when tar stores the name of the file that it's archiving, it removes any leading / character. This is so that when the tarball gets extracted, nothing on the system gets overwritten without the sysadmin's intervention.

When you say to tar up /foo, tar will print that warning, and then act like you cd'ed into / and told it to tar up foo (so that when you extract the tarball, the files won't go into /foo unless you extract it from your root directory; by default, it'll create a directory named "foo" wherever you extract it from instead).