LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-17-2008, 09:59 AM   #1
tostay2003
Member
 
Registered: Jun 2006
Posts: 126

Rep: Reputation: 15
tar unpacking causing problems


Hi
I have code as below,

Code:
tar cf - /PathA/DirectoryA /PathA/directoryB | gzip > /PATHA/wrap.tar.gz
cd /PathA/directoryB
gunzip -c /PATHA/wrap.tar.gz | tar xf -
a) Where I try to pack two directories (files/directories within them), zip them.

b) Then change directory.

c) Then unpack

What is happening here is that the unpacked data is creating DirectoryA and DirectoryB in PathA instead of the changed path i.e. /PathA/directoryB.

Any ideas why it is happening.
 
Old 01-17-2008, 11:38 AM   #2
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,437
Blog Entries: 1

Rep: Reputation: 66
This is right as you specify "/PathA/whatever" as a tar argument. So tar create a backup of "PathA" files/dir not just "whatever".

What I presume you want is:
Code:
cd /PathA
tar -cf - DirectoryA DirectoryB | gzip > /PathA/wrap.tar.gz
cd /PathA/DirectoryB
gunzip -c /PathA/wrap.tar.gz | tar xf -
to get something like this: (sorry for the primitive ascii art)
Code:
/PathA--+--DirectoryA
        +--DirectoryB--+--DirectoryA
        |              +--DirectoryB  
        +--wrap.tar.gz
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need some help w/ unpacking a tar.gz & directory stuff davidbix Linux - Newbie 2 10-21-2005 08:01 PM
Unpacking a .tar.bz2 file njschroe Linux - Software 1 01-31-2005 04:25 PM
unpacking .tar.gz files crazibri Linux - Newbie 5 03-24-2004 03:19 AM
unpacking tar file Longinus Slackware 4 12-14-2003 03:04 AM
unpacking multiple .tar.gz files illtbagu Linux - General 5 01-18-2003 06:43 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration