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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tar & directory structure

Status
Not open for further replies.

disord3r

Programmer
Apr 12, 2002
189
US
I'm creating zipfiles like so:

tar czf /[path_to_archive]/archive.tar.gz /[full_path]/file1 /[full_path]/file2 etc...

When I go to decompress/extract these files later, I find that the original directory structure was included in the archive. Is there a way to prevent it from storing the path from it's origin?

Note: I asked this same question somewhere else, and was told that, upon extraction, I should simply tell WinZip to ignore the structure in the archive. I'm more concerned with preventing the directory structure of my box from appearing in the archive in the first place.

So, what can I do here?
 
You might like to consider cding to the appropriate directory first, then doing your tar. This will exclude any of the path above the directory you are in. HTH.
 
Alternatively, if you have a complex directory structure, flatten it first by copying all the files to another temporary directory, and then create your tar from there.

[tt]find /complex/dir -type f -exec cp -i {} /temporary/dir \;
cd /temporary/dir
tar cvf whatever.tar *[/tt]

Naturally all of the filenames in the source directory tree should be unique!


Annihilannic.
 
Your tar have maybe a -D option

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top