Extract contents of tar ball without extracting files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extract contents of tar ball without extracting files
# 1  
Old 02-24-2012
Extract contents of tar ball without extracting files

Hi,

I'm using a tar command
Code:
tar -xOvf /home/mytar.tar

My intention is to extract data in files which are inside various directories,
without extracting files to the disk.

Is this the best way to achieve it?

Thanks,
Chetan

Last edited by Franklin52; 02-24-2012 at 03:32 AM.. Reason: Please use code tags for code and data samples, thank you
# 2  
Old 02-24-2012
You have to store data somewhere. We have two choices - memory or mass storage (tape, disk, etc). You just eliminated one, so we are left with memory. That means a program has to receive the data

When tar outputs, not just data comes out, also metadata. So you get to filter it out, I don't know how to do that a priori.

Code:
tar xvf somefile.tar  /full/path/to/file/to/extract.dat | ( your program lives in here )

Your program has to read from stdin, pitch metadata, and then keep real data. I wonder what you do with it then if you don't put some of it to disk or the tty.

The only point I would make is this is an odd request as tar is inherently slower than disk I/O, so why would you do all this? No spare disk space?
# 3  
Old 02-24-2012
Thanks for the response.

Actually i am sending this data out into datastage so that i can use the data for further processing.
The reason for me to try this is, the requirement states that these files should not be extracted to the disk.No scope for I/O.
Yes as you mentioned this is very slow.So wanted to check if I'm doing this right.
So there is no other way to this apart from what I'm doing?

Thanks.
# 4  
Old 02-24-2012
It always helps to post your Operating System and version and what Shell your are using.

Depending on the O/S you may find that the more modern unix program "pax" is useful for reading "tar" archives. Especially for picking out single files.

When trying out "tar" or "pax" commands always rehearse on an expendable test archive.

When creating a "tar" archive always use relative paths otherwise you can only restore to the original location. Perhaps your "tar" archive has absolute paths. The "pax" program does not have this limitation.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Create Tar ball

Hi Team, Following unix command is throwing error. Can anyone please help me to fix the issue? tar -cvf /aa/bb/cc/tarball1.tar /x/y/z1/abc.ksh /x/y/z2/pqr.txt /x/y/z3/lmn.tmp Error message thrown: tar: Removing leading `/' from member names OS: uname -a Linux xyz... (1 Reply)
Discussion started by: kmanivan82
1 Replies

2. Shell Programming and Scripting

Problem creating a tar ball in different directories

Hi all. I'm hitting a problem creating a tar archive in one directory from files located in a different directory. It fails when I replace the absolute paths with variables in the script but works if I just run tar on the cmdln. E.g. #!/bin/ksh BASE=$PWD STAGE=$BASE/stage LOG=$BASE/log... (4 Replies)
Discussion started by: user052009
4 Replies

3. Shell Programming and Scripting

Untar only folder structure from a tar ball

I have a tar file hello.tar which is 95 GB. hello.tar has many files and folders including some tar files as well. I wish to create a new tar ball which should maintain only the folder structure of hello.tar and the tar ball within the hello.tar So basically the idea is to untar... (2 Replies)
Discussion started by: mohtashims
2 Replies

4. Shell Programming and Scripting

Need Tar Ball command to exclude directories

Hi, uname -a SunOS mymac 5.11 11.2 sun4u sparc SUNW,SPARC-Enterprise I need to tar a folder /tmp/moht but do not want these three folders to be included in the tar file -> savejpg, bmpsave and imgsave I tried --exclude, -path, -not options but it says bad option Can you help me with... (3 Replies)
Discussion started by: mohtashims
3 Replies

5. Shell Programming and Scripting

Extract a tar ball into multiple directories

#cat a BAC064DAL BAC063DAL BAC056PHX BAC066DAL BAC062PHX BAC062DAL BAC060DAL BAC058PHX BAC054PHX BAC051PHX # for i in `cat a` > do > tar xvf $a/$a*.tar* > done tar: /*.tar*: Cannot open: No such file or directory tar: Error is not recoverable: exiting now tar: /*.tar*: Cannot... (3 Replies)
Discussion started by: kenshinhimura
3 Replies

6. UNIX for Dummies Questions & Answers

Listing contents of .tar.gz files

Hi All, I would like to know couple of ways to list the content available in tar and gzipped file without extracting. i.e., I would like to display the contents of test.tar.gz without extracting. Note :: please suggest a command other that tar -ztvf (9 Replies)
Discussion started by: Girish19
9 Replies

7. UNIX for Advanced & Expert Users

Extracting directories only from tar ball

Hi Somebody must have done this before, but I can't seem to find any answer on my problem. On HP-UX 11i v3 I have a relatively large tar ball (~120 GB), and I want to create the directory structure only from the archive. There is no option to make a new archive with only the directory... (3 Replies)
Discussion started by: hpvm_adm
3 Replies

8. Shell Programming and Scripting

Extract files from tar ball without directory structure

Hi, I have tar filw which has multiple directories which contain files. When i extract using tar -xf the directory structure also get extracted. I require only files and not directory structures as there will be overhead of moving the files again. So i searched here and got a solution but... (4 Replies)
Discussion started by: chetan.c
4 Replies

9. UNIX for Advanced & Expert Users

Size of a tarball without untarring - Catch parent tar ball has sub tars

hi, I am in a weird situation. I have a parent tarball which contains 2 sub tarballs. The structure is such : Parent.tar.gz ---- > child1.tar.gz and child2.tar.gz I need to get the size of the parent tarball without untaring it I know that the command is gunzip -c parent.tar.gz | wc -c ... (1 Reply)
Discussion started by: mnanavati
1 Replies

10. Shell Programming and Scripting

Extracting .tar files.

Hey guys complete n00b here so I'll try my best at explaining. I'm creating a backup and restore utility and decided to use tar. I create a backup folder in each user's account and when backing up (say word processing files), I use the following: tar cvf /home/user/backup/wpbackup.tar... (2 Replies)
Discussion started by: EwanD
2 Replies
Login or Register to Ask a Question