LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-21-2013, 08:06 PM   #1
ravindert
Member
 
Registered: Oct 2011
Posts: 68

Rep: Reputation: Disabled
tar : how to extract only one directory from a backup


Hi All,

Can any help to find that how to extract the particular folder from the test.tar.gz file. I do not want to extact the whole tar.gz file.


Thanks!!!!!!!!
Ravinder
 
Old 08-21-2013, 08:10 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,130
Blog Entries: 2

Rep: Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825
It is as simple as
Code:
tar xf test.tar.gz /folder/to/extract
More useful tar examples here: http://www.thegeekstuff.com/2010/04/...mand-examples/
 
Old 08-21-2013, 08:11 PM   #3
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_10{.0|.1|.2}
Posts: 3,876
Blog Entries: 1

Rep: Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998
Hmmm...

Use the -T option.

First make a list of the files in the directory you want to extract, save to file...

Code:
tar -tf archive.tar |grep 'directory/path' >files.txt

then

tar -x -T files.txt -f archive.tar
[EDIT]
Or follow TobiSGD's method
[/EDIT]

Last edited by astrogeek; 08-21-2013 at 08:13 PM.
 
Old 08-21-2013, 08:12 PM   #4
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
simply follow with the file/dir you want

for example

Code:
tar xf test.tar.gz myfolder
if you just want to get a list first

Code:
tar tf test.tar.gz
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
tar - extract to different directory hcclnoodles Linux - Newbie 4 03-05-2011 04:47 PM
tar extract specific directory lrt Linux - Software 7 12-01-2007 09:40 AM
How to extract specific directory from a TAR file? Micro420 Linux - General 4 04-18-2007 01:04 AM
tar: how to extract only one directory from a backup guarriman Linux - General 1 01-29-2007 11:35 AM
How To extract .tar.gz To A Specific Directory? George2 Linux - Software 4 02-18-2006 08:01 AM


All times are GMT -5. The time now is 04:49 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration