LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to untar a file in another directory other then current directory. (https://www.linuxquestions.org/questions/linux-software-2/how-to-untar-a-file-in-another-directory-other-then-current-directory-451219/)

dr_zayus69 06-03-2006 10:41 AM

How to untar a file in another directory other then current directory.
 
hi. I've searched on here and looked in the tar manpage and couldn't find what i was looking for. I was wondering how you can choose to unpack the contents of a tar file to another directory other then the current directory. Do you use the -C option or is that for chosing a directory to tar? thanks for any help in advance.

Centinul 06-03-2006 11:08 AM

Here is what I found from the manpage:

Code:

-C (or --directory) Change to directory before processing the remaining arguments.
I'm pretty sure you can use the -C option when un'taring. Although when it is used when you tar it is order sensitive. Hope this helps.

dr_zayus69 06-03-2006 11:32 AM

thanks. I saw that too but when i tried it the directory i tried was long so the -xjvf options i used was split so vf was on another line. I got an error that said this option needs the f switch so i thought it meant i needed it because it thought i was trying to tar the directory. In that situation how would i let tar know that it is all one command? thanks for your help.

Centinul 06-04-2006 05:11 PM

have you tried:

Code:

tar -xjvf -C DIRECTORY file.tar
Or something along those lines? Sorry, it's been a while since I used tar.

dr_zayus69 06-04-2006 05:26 PM

no i tried tar -C /path/to/directory -xzvf file.tar.gz. i wasn't sure if you needed to put the -C option before or after the options or if it mattered.

ghatamos 06-05-2006 09:38 AM

i'm just wondering, why do you need to do that step?

won't it be easy to just go to the directory where you want to untar the package and then give the command from there?

or is it that you are using this command in a script?

dr_zayus69 06-05-2006 12:40 PM

yeah it would be good for a script but i was untarring a skin for gmplayer and i didn't want to keep the tar file in the directory for the skin but wanted to keep the tar file around.

chrism01 06-05-2006 08:27 PM

Theoretically the order shouldn't matter, but the convention is
utilname
then
flags-without-args
then
flag-with-arg
flag-with-arg
.
.
etc

moymexico 05-16-2007 11:01 AM

untar a file in another directory
 
I arrive here looking for the same answer... trying what you suggested, finally I found:

tar -C DIRECTORY -xvf file.tar

example
I want to extract dat-5031.tar in /usr/local/uvscan/

tar -C /usr/local/uvscan/tmp/ -xvf /datos/updates/dat-5031.tar

Hope this helps...
Moy


All times are GMT -5. The time now is 09:05 PM.