LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-14-2004, 04:17 AM   #1
dshafi
LQ Newbie
 
Registered: May 2003
Location: chennai
Distribution: redhat
Posts: 27

Rep: Reputation: 15
tar problems


Dear All
i have a tar file i want to extract a particular file or dir from a tar.can ayone help me
 
Old 07-14-2004, 04:22 AM   #2
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
What is the name of the file? Take a look here:

http://www.linuxquestions.org/questi...threadid=45094

it's a good howto about installing programs (and uncompressing them as well).
 
Old 07-14-2004, 05:43 AM   #3
dshafi
LQ Newbie
 
Registered: May 2003
Location: chennai
Distribution: redhat
Posts: 27

Original Poster
Rep: Reputation: 15
tar problems

like one example


i am creating a dir #mkdir -p test1/test2/test3/test4

and then i am doing # tar -cvf test.tar /test1/


i created a tar test.tar that contains all dirs (test1,test2,test3,test4)

Now what i want is when i extract tar -xvf i want only a particular dir example test4

if there any option is there
 
Old 07-14-2004, 11:31 AM   #4
meshking
LQ Newbie
 
Registered: Apr 2004
Posts: 8

Rep: Reputation: 0
Yes, there is a method to do this with tar.

if your tar file has subdirectories:

/test1/bin
/test1/lib
/test2
/test3

listed when you tar tvf <yourTarFile.tar>

then just type tar xvf <yourTarFile.tar> /test1/lib

This should extract the /test1/lib to <yourCurrentDir>/test1/lib

HTH
 
Old 07-15-2004, 01:21 AM   #5
dshafi
LQ Newbie
 
Registered: May 2003
Location: chennai
Distribution: redhat
Posts: 27

Original Poster
Rep: Reputation: 15
i am creating a dir #mkdir -p /test1/test2/test3/test4

and then i am doing # tar -cvf test.tar /test1/*


after creating tar i removed all rm -rf /test/*


then now i need only test4 dir

when i do # tar -xvf test.tar test4

its not working it says test4 not found in archive
 
Old 07-15-2004, 02:30 AM   #6
meshking
LQ Newbie
 
Registered: Apr 2004
Posts: 8

Rep: Reputation: 0
Quote:
Originally posted by dshafi
i am creating a dir #mkdir -p /test1/test2/test3/test4

and then i am doing # tar -cvf test.tar /test1/*


after creating tar i removed all rm -rf /test/*


then now i need only test4 dir

when i do # tar -xvf test.tar test4

its not working it says test4 not found in archive
No, you need to use the full path, since you tar'd from /test1/ you will need the command:

#tar -xvf test.tar test1/test4

Having looked through the man, I can't see how you can get the dir to be extracted to . and not /test1/test4 however.
 
Old 07-15-2004, 06:08 AM   #7
dshafi
LQ Newbie
 
Registered: May 2003
Location: chennai
Distribution: redhat
Posts: 27

Original Poster
Rep: Reputation: 15
tar -xvf test.tar test1/test2
test1/test2/
test1/test2/test3/
test1/test2/test3/test4/


when i do this all of them to be extracting test1,test2,test3,test4 i dont want like this i wants to extract only the particular dir say dir2 instead of getting all of the test1,test2,test3,test4
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 02:48 AM
tar tar cvf - . | (cd /root/; tar xvf -) ewt3y Linux - General 10 02-19-2014 10:55 AM
installation problems with libxml2-2.2.66.tar.gz and libxml2-devel2-2.6.20-3.tar.gz g-string 3 Linux - Software 6 11-24-2005 11:39 AM
tar problems yanik Debian 13 09-08-2005 04:11 PM
Diferance between rpm, tar, tar.gz, scr.tar, etc mobassir Linux - General 12 08-21-2003 06:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:53 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
Open Source Consulting | Domain Registration