LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-21-2005, 05:24 PM   #1
timmy01
LQ Newbie
 
Registered: Sep 2003
Posts: 22

Rep: Reputation: 15
untar in another dir


hi,

small question,
but handy if i know how it works
(i cant find it anywhere)

i am trying to untar a tar file into another dirrectory

like this:

> tar -xzvf test.tar > dir/

i tried everything but nothing works
and get only the error
-bash: dir: Is a directory


if this is not possible
can i than copy the content of a whole dir into another dir?

please advise me with the command...

thanks
Tim
 
Old 06-21-2005, 06:12 PM   #2
Andrew Benton
Senior Member
 
Registered: Aug 2003
Location: Birkenhead/Britain
Distribution: Linux From Scratch
Posts: 2,073

Rep: Reputation: 64
tar xjf test.tar.bz2 -C /path/to/dir
 
Old 06-21-2005, 06:24 PM   #3
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,137
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
Look at the Man page for tar, it gives you the correct syntax
Code:
man tar
I think it should be
tar -xzvf /home/yourname/filename /anotherdir/etc/filename

You'll need to have permission to write to that dir of course.
 
Old 06-21-2005, 06:32 PM   #4
timmy01
LQ Newbie
 
Registered: Sep 2003
Posts: 22

Original Poster
Rep: Reputation: 15
well...

this looks more like zipping the file
instead of UNzipping it...

i tried the command but its not working

i think i should be starting something like:

> tar -zxvf test.tar ...................

but the last part should be it whats missing

Ps. if this is not possible does anyone know
a way to copy the whole contents of a dir.
into another dir....?

Tim
 
Old 06-21-2005, 11:43 PM   #5
mhearne
Member
 
Registered: Nov 2004
Location: Amarillo, TX
Distribution: Mandriva
Posts: 91

Rep: Reputation: 15
This worked for me, but I had to use the full pathname. Using tar -zxf test.tar.gz -C projects didn't work. In my home directory:

$ vi test.txt
$ tar -zcf test.tar.gz test.txt
$ tar -zxf test.tar.gz -C /home/mhearne/projects
$ ls projects
test.txt

Michael
 
Old 06-22-2005, 03:44 AM   #6
timmy01
LQ Newbie
 
Registered: Sep 2003
Posts: 22

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by mhearne
This worked for me, but I had to use the full pathname. Using tar -zxf test.tar.gz -C projects didn't work. In my home directory:

$ vi test.txt
$ tar -zcf test.tar.gz test.txt
$ tar -zxf test.tar.gz -C /home/mhearne/projects
$ ls projects
test.txt

Michael
yes this works.

but the thing is that i have more than one file
so i zipped the whole dir. with 10 files in them.
Now these files i wanna unpack in different dirs.

but that is not possible... cos unpacking means
putting the dir theire. but in fact i only want the
content of that dir unpacked in another dir..

Still got it? :-)
 
Old 06-22-2005, 11:44 AM   #7
mhearne
Member
 
Registered: Nov 2004
Location: Amarillo, TX
Distribution: Mandriva
Posts: 91

Rep: Reputation: 15
Hi Timmy01,
Doing the same thing with a whole dir also works for me:

$ tar -zcf projects.tar.gz projects
$ tar -zxf projects.tar.gz -C /home/mhearne/tmp
$ls tmp
projects/

But, if you want to move it to an area that you don't own, then you may have to be root or have sudo privileges.

Michael

Last edited by mhearne; 07-05-2005 at 11:00 PM.
 
  


Reply



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
Untar Dharma_bum07 Linux - Newbie 2 11-26-2004 10:16 AM
howto make a dir shared that is not in my home dir Schmurff Linux - Newbie 2 06-19-2004 07:54 PM
krecipes and ./configure -with-qt-dir=DIR disco rugby Linux - Software 4 06-13-2004 09:06 PM
untar imsajjadali Red Hat 3 01-29-2004 01:47 AM
Bash script (untar *.tar files and then cd to the untared dir) k0ljat Linux - Newbie 2 12-30-2003 05:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:39 AM.

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
Open Source Consulting | Domain Registration