Extract contents of tar ball without extracting files

Hi,

I'm using a tar command

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

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.

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?

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.

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.