LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   simple tar xvf question (https://www.linuxquestions.org/questions/linux-newbie-8/simple-tar-xvf-question-4175434760/)

atjurhs 10-30-2012 10:29 AM

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

pixellany 10-30-2012 10:59 AM

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??

shivaa 10-30-2012 11:10 AM

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.

evgenyz 10-30-2012 11:15 AM

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

atjurhs 10-30-2012 04:01 PM

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/


evgenyz 10-30-2012 05:49 PM

Can you NFS mount the file system from your remote computer?

atjurhs 10-30-2012 07:27 PM

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

chrism01 10-30-2012 07:36 PM

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.

acrowder 10-31-2012 11:32 AM

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.

atjurhs 10-31-2012 01:02 PM

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.

segmentation_fault 10-31-2012 02:37 PM

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.

atjurhs 11-01-2012 09:06 AM

Segi - that's it, thanks! I new it had to be an easy thing

acrowder 11-01-2012 11:06 AM

didn't know that was there, but it makes sense that it would be.

man pages are your friends.


All times are GMT -5. The time now is 03:00 PM.