LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   untar in another dir (https://www.linuxquestions.org/questions/linux-software-2/untar-in-another-dir-335890/)

timmy01 06-21-2005 05:24 PM

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

Andrew Benton 06-21-2005 06:12 PM

tar xjf test.tar.bz2 -C /path/to/dir

teckk 06-21-2005 06:24 PM

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.

timmy01 06-21-2005 06:32 PM

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

mhearne 06-21-2005 11:43 PM

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

timmy01 06-22-2005 03:44 AM

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? :-)

mhearne 06-22-2005 11:44 AM

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


All times are GMT -5. The time now is 02:14 AM.