LinuxQuestions.org
Review your favorite Linux distribution.
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 01-24-2006, 10:12 PM   #1
punt
Member
 
Registered: Jun 2001
Distribution: Fedora 22
Posts: 371

Rep: Reputation: 30
How do I extract only part of a tarball?


On a whim when backing up my harddrive before it crashed for good, I created a tarball of my /data directory: it is 70GB. It will take forever and a day to extract this, and I don't need ALL of the files -- just a few important ones.

I was wondering if there's a way to extract part of a tarball. I know the directory structure so it's just a matter of singling it out when using the tar command.

Thanks!
 
Old 01-24-2006, 11:00 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Guess: an archive is an archive--you have to open it to see what's there.

What does "man tar" say?
Does it really take long to untar 70GB? (I've never tried it)
 
Old 01-24-2006, 11:04 PM   #3
Boby
Member
 
Registered: Feb 2004
Posts: 781

Rep: Reputation: Disabled
Tuff question

I was never thinking for this one, I have always used in this case the graphical archieve manager or ark.

But this is what I think you can do (exclude unvanted files)
Code:
tar -xvf your_archive.tar --exclude file_1.txt --exclude file_2.rpm
Took it from the manual:
Code:
man tar
Hope it helps.

Quote:
Does it really take long to untar 70GB?
Whit that file, it can take some time.

Boby

Last edited by Boby; 01-24-2006 at 11:12 PM.
 
Old 01-25-2006, 02:58 AM   #4
linmix
Senior Member
 
Registered: Jun 2004
Location: Spain
Distribution: FC5
Posts: 1,993
Blog Entries: 1

Rep: Reputation: 46
As Boby pointed out, if you use a graphical archive manager (Ark, file-roller) you can see what's inside the tarball and then select the files or directories you want to extract and also where to extract them.
 
Old 01-25-2006, 08:43 AM   #5
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
tar also supports selection of certain files, using wildcards to extract from archives. Just be careful for shell filename expansion.

Example:
tar -xvf your_tar_file 'dir1/*'
Notice the single quotes around the filename with wildcards, to prevent the shell from interpreting the * before passing it to tar.
 
Old 01-25-2006, 02:44 PM   #6
punt
Member
 
Registered: Jun 2001
Distribution: Fedora 22
Posts: 371

Original Poster
Rep: Reputation: 30
Thanks for the tips. I've never really grasped everything from the man pages; don't get the impression that I haven't looked there -- I just didn't know where to go from there and my syntax wasn't working out.
 
Old 01-26-2006, 01:57 AM   #7
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
For the GNU tar command, consider doing
tar --help
instead of
man tar.

The --help lists all the options, in a short, readable way and is thus handier then reading the entire man page (which can be lengthy, I know...).
 
  


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
Extract the used part of dynamic library for my application??? okeyla Programming 1 12-21-2005 02:24 PM
After Tarball then what ? sevvy8 Linux - Newbie 2 03-29-2004 03:41 AM
Does it matter where you extract a tarball? john_walsh54 Linux - Newbie 3 10-05-2003 03:37 AM
How to extract a part of a line by sed? J_Szucs Programming 2 02-15-2003 06:49 PM
Tarball? HardcoreGamer Linux - Software 4 02-12-2003 02:26 PM

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

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