LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-03-2006, 10:41 AM   #1
dr_zayus69
Member
 
Registered: Sep 2004
Location: western massachusetts
Distribution: fedora core 3, Suse 10
Posts: 877

Rep: Reputation: 35
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.
 
Old 06-03-2006, 11:08 AM   #2
Centinul
Member
 
Registered: Jun 2005
Distribution: Gentoo
Posts: 552

Rep: Reputation: 30
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.

Last edited by Centinul; 06-03-2006 at 11:10 AM.
 
Old 06-03-2006, 11:32 AM   #3
dr_zayus69
Member
 
Registered: Sep 2004
Location: western massachusetts
Distribution: fedora core 3, Suse 10
Posts: 877

Original Poster
Rep: Reputation: 35
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.
 
Old 06-04-2006, 05:11 PM   #4
Centinul
Member
 
Registered: Jun 2005
Distribution: Gentoo
Posts: 552

Rep: Reputation: 30
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.
 
Old 06-04-2006, 05:26 PM   #5
dr_zayus69
Member
 
Registered: Sep 2004
Location: western massachusetts
Distribution: fedora core 3, Suse 10
Posts: 877

Original Poster
Rep: Reputation: 35
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.
 
Old 06-05-2006, 09:38 AM   #6
ghatamos
Member
 
Registered: Nov 2003
Posts: 35

Rep: Reputation: 15
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?
 
Old 06-05-2006, 12:40 PM   #7
dr_zayus69
Member
 
Registered: Sep 2004
Location: western massachusetts
Distribution: fedora core 3, Suse 10
Posts: 877

Original Poster
Rep: Reputation: 35
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.
 
Old 06-05-2006, 08:27 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Theoretically the order shouldn't matter, but the convention is
utilname
then
flags-without-args
then
flag-with-arg
flag-with-arg
.
.
etc
 
Old 05-16-2007, 11:01 AM   #9
moymexico
LQ Newbie
 
Registered: May 2007
Posts: 2

Rep: Reputation: 0
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
 
  


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
How to untar all tar-files in a directory? zoomzoom Linux - Newbie 13 05-09-2017 11:52 AM
find in current directory ramanadyv Linux - Newbie 3 03-28-2006 10:12 PM
untar a single directory of a large taiwf Linux - General 1 02-22-2006 02:53 AM
couldn't get to current directory Paxmaster Linux - Newbie 0 11-22-2004 12:37 PM
Untar to a directory john8675309 Linux - Software 2 03-14-2004 09:12 PM

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

All times are GMT -5. The time now is 12:31 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