Read just a part of an Archive file

I have a file, bigfile.tar which is 800MB uncompressed, and 500MB when compressed (bigfile.tar.gz). Now, none of my partitions has more than 300MB free. I need to read just a part of this archive, perhaps just a few files or a directory. Can I do that or do I have to buy a new hard disk?

Better keep your money for something else.

First, let me point out that, given the above situation, Midnight Commander will not be able to read into the file, when you press Enter on bigfile.tar.gz, because it still needs space to store temporary files (probably the same amount of space needed when decompressing and de-tarring the file). Midnight Commander will just fill up the /tmp directory on the root partition and will finally fail with a 'disc full' message :-( So this does not solve the problem. Even worse, after trying and not succeeding, remember to go to /tmp and erase the big files that Midnight created and could no longer erase, because it ended in error.

Luckily, there is a smart and relatively simple solution to this.
First, if you don't have it already, generate a list of the files in the archive:
gzip -c -d /mnt/cdrom/bigfile.tar.gz | tar -tv  > bigfile.list
Now take a look at the resulting bigfile.list to see exactly what you need (in this example, I need to extract my entire PROG directory, fdonea/PROG).
gzip -c -d /mnt/cdrom/bigfile.tar.gz | tar -xv fdonea/PROG

Have a Unix Problem
Do you have a UNIX Question?

Unix Books :-
UNIX Programming, Certification, System Administration, Performance Tuning Reference Books

Return to : - Unix System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.