LinuxQuestions.org
Help answer threads with 0 replies.
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 10-30-2012, 11:29 AM   #1
atjurhs
Member
 
Registered: Aug 2012
Posts: 179

Rep: Reputation: Disabled
simple tar xvf question


Hi guys,

I'm trying to untar a file "tarfile.tar"

It's VERY large and contains multiple file types and multiple directories.

I only want those files with "_MP_" in their name, and there are _MP_ files are located within each directory.

These tarfiles are located on a server that I can't write to, and because of their size, I don't want to copy the whole tarfile.tar to my machine, I only want the _MP_ files on my machine. Fortunaetly the _MP_ files names are unique so they won't write over themselves when extracting

I tried

Code:
tar -xvf tarfile.tar --wildcards '*_MP_*' /home/tabitha/my_data/
but I get errors of "Not found in archive" and I know they are in there

can someone tell me shat I did wrong?

Thanks so much!

Tabby
 
Old 10-30-2012, 11:59 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
I can't find the usage of wildcards in the tar man page---I wonder if the string should be in double-quotes?

The first thing I would do is run some tests on a smaller archive to make sure the syntax is right.

Quote:
It's VERY large
HOW large??
 
Old 10-30-2012, 12:10 PM   #3
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Before extracting the tar, you should check content of the tarfile using:-
Code:
tar -tvf tarfile.tar
Could you specify the name of any one of the MP file (full name), so people can suggest you some search filter.
 
Old 10-30-2012, 12:15 PM   #4
evgenyz
Member
 
Registered: Sep 2012
Posts: 48

Rep: Reputation: Disabled
According to tar man: --wildcards
use wildcards with --exclude
If you want just to match the pattern of retrieved files use such as following (I just used it in my system):
tar xvf ../x.tar *00002457170*
It restored only the files matching above pattern
 
1 members found this post helpful.
Old 10-30-2012, 05:01 PM   #5
atjurhs
Member
 
Registered: Aug 2012
Posts: 179

Original Poster
Rep: Reputation: Disabled
pixellany - "VERY large" means that some of the tarballs are as large as 300+ Gigabytes

shivaa - when I use the tvf option I can see all the files and folders and subfolders inside the tarball. A typical file name of a file that I would want would be:

dp1_MP_xx_2012_10_30_00_BIAS.bff

The other files would have the same names except the MP would be replaced by FK or DM or EM etc...

I found I can use

Code:
tar xvf tarball.tar dp1_MP_xx_2012_10_30_00_BIAS.bff
tar xvf tarball.tar *_MP_*
tar xvf tarball.tar *dp1_MP_xx*.bff
the last command seems to work for all the MP files in the tarball no matter what folder or sub folder they are in - YEA


THE OTHER PROBLEM IN THIS:

Code:
These tarfiles are located on a server that I can't write to, and because they can be 300+ gigabytes in size, I don't want to copy the whole tarball to my machine.


So how do I redirect the tar extracting command to output only the MP files to /home/tabitha/my_data/

Last edited by atjurhs; 10-30-2012 at 05:33 PM.
 
Old 10-30-2012, 06:49 PM   #6
evgenyz
Member
 
Registered: Sep 2012
Posts: 48

Rep: Reputation: Disabled
Can you NFS mount the file system from your remote computer?
 
Old 10-30-2012, 08:27 PM   #7
atjurhs
Member
 
Registered: Aug 2012
Posts: 179

Original Poster
Rep: Reputation: Disabled
No, it's not my network

There must be a simple tar command that says, instead of extracting the files in the tarball to the directory it is located in, extract them to some user designated path
 
Old 10-30-2012, 08:36 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,258

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
You need to google tar extract over ssh.

Also, see the comment by Carlos here http://www.cyberciti.biz/faq/howto-u...r-ssh-session/, which seems to mesh with
Quote:
--force-local
archive file is local even if it has a colon
http://linux.die.net/man/1/tar
Seems to agree with Carlos ie if you don't specify that flag, it will go to the other box to get the tar archive, instead of having to explicitly call ssh.
 
Old 10-31-2012, 12:32 PM   #9
acrowder
LQ Newbie
 
Registered: Oct 2012
Location: NY
Distribution: debian
Posts: 3

Rep: Reputation: Disabled
might sound crazy, but i would suggest for simplicity that you make your own machine ssh accessible, then run your tar command on the remote server in a manner similar to the tutorial linked above.

i.e. (while SSH'd into remote server)
Code:
tar xvf tarball.tar *_MP* | ssh user@home_pc "dd of=smallertarball.tar"
maybe that won't work, but it's an idea - and, I think, probably easier than figuring this out some other way.

Last edited by acrowder; 10-31-2012 at 12:37 PM.
 
Old 10-31-2012, 02:02 PM   #10
atjurhs
Member
 
Registered: Aug 2012
Posts: 179

Original Poster
Rep: Reputation: Disabled
so it turns out that my machine is NFS mounted, not sure what that really means, but maybe that will help???

what if the tarball was somewhere on my machine in say a tmp folder and I wanted to untar it in /home/tabitha/my_data/

couldn't I just do something like:

tar xvf tarball.tar > /home/tabitha/my_data/

and I know that's not right and won't work, but it just seems like there should be a simple way to redirect the output of the tar extract command.
 
Old 10-31-2012, 03:37 PM   #11
segmentation_fault
Member
 
Registered: Sep 2008
Location: Ioannina, Greece
Distribution: Gentoo
Posts: 332

Rep: Reputation: 55
Are you looking for the -C option? (that's a capital 'c')
Quote:
-C, --directory DIR
change to directory DIR
This will extract the files in the specified DIR.
 
1 members found this post helpful.
Old 11-01-2012, 10:06 AM   #12
atjurhs
Member
 
Registered: Aug 2012
Posts: 179

Original Poster
Rep: Reputation: Disabled
Segi - that's it, thanks! I new it had to be an easy thing
 
Old 11-01-2012, 12:06 PM   #13
acrowder
LQ Newbie
 
Registered: Oct 2012
Location: NY
Distribution: debian
Posts: 3

Rep: Reputation: Disabled
didn't know that was there, but it makes sense that it would be.

man pages are your friends.
 
  


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 tar cvf - . | (cd /root/; tar xvf -) ewt3y Linux - General 10 02-19-2014 11:55 AM
What is the difference between the commands tar -xvf and tar - xzf kenholtmeyer Linux - Newbie 4 08-03-2011 04:29 PM
tar xvf does nothing and exits with 0 crisostomo_enrico Solaris / OpenSolaris 20 09-20-2007 11:57 AM
Simple Tar Question otisthegbs Linux - Software 1 08-24-2004 02:47 PM
Tar xvf I get segmentation fault lvt lists ok Help! Bob Ross Red Hat 0 01-27-2004 11:45 PM


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