On 2007-08-09, CBFalconer <cbfalconer@yahoo.com> wrote:
> Keith Keller wrote:
>>
>> If you want to extract only certain files from a tar file, it's easy
>> enough to do. You still have a possibly long read of the file, but you
>> can certainly avoid the long write and disk use if you know what files
>> you're looking for. And I don't see how zip gets around that issue,
>> so I don't see how zip is any more or less useful than tar/gzip.
>
> For a tar file, yes. For a gzipped tar file (the OP talked about
> tar.gz or tar.bz2) any access first requires decompressing the
> entire large file, and then searching the result. Just because you
> have adequate disk space doesn't mean it always exists.
For a gzip'd tar file, any access requires on-the-fly decompression, but
not necessarily to disk. It's the moral equivalent of piping gzip -dc
(which uses no disk, except perhaps to /tmp) to tar (which can use only
the disk you tell it to).
For example:
tar xzf foo.tar.gz foo/bar/baz.c foo/baz/bar.c
extracts at most two files from foo.tar.gz. If foo.tar.gz is large, the
tar will take a long time, but no matter how large it won't eat any more
space than baz.c and bar.c take.
If for some reason your tar doesn't support gzip compression (or bzip2),
you can always do
gzip -dc foo.tar.gz | tar xf - foo/bar/baz/c foo/baz/bar.c
which is the same as above except with two processes instead of one.
(And one of my pet peeves is to find my users with foo.tar in their
directory after downloading foo.tar.gz. Grr!)
--keith
--
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information