On 06/09/2010 08:46 AM, Patrick O'Callaghan wrote: > On Tue, 2010-06-08 at 16:36 -0700, Suvayu Ali wrote: > >>> To extract only a specific file: >>> $ tar xf bobg.tar.gz the/file/you/want >>> >>> >> I think the OP's worry is not whether it can be done, but he wants to >> avoid the time and CPU cycles involved in the gunzip step. Since he >> has his entire home directory in the tarball, even extracting a single >> file requires tar to decompress the entire tarball before it can >> extract that one file. >> > Without looking at the source code one can't be sure, but I'd be > surprised if that were literally true. IOW I doubt that tar decompresses > everything to a temp file and then searches for the target. It should > only be necessary to decompress up to the position of the target file > (recall that tar originally meant "tape archiver", i.e. it's very > focussed on doing things in a single sequential pass). I assumed that > was what the OP wanted to do, and I believe the solution offered > achieves it. Furthermore, given that the Gzip compression algorithm is > stream-based, there cannot by definition be any substantially more > efficient way of doing it other than decompressing the stream up to the > point of interest. > > The alternative archive method (compress each file and then tar up the > result), would be somewhat easier to extract in this specific case, but > at the cost of a poorer compression ratio. It's the old space/time > tradeoff once again. > > > If one does a "tar -xf bobg.tar.gz the/file/you/want" it is easy to see that gzip is consuming the highest cpu and that it is using a pipe file as is tar. No temp files are created. I don't know about anyone else here.... But if I have a large tar archive I include as the first file in the archive a "ls" of what is in the archive. So when I forget what is really in the archive I simply first extract the "ls" find what I want and then do the extract as you have indicated. To me, archiving a bunch of smaller tars, zips, etc. doesn't make much sense as it makes it harder for me to find what I am looking for, i.e. lost. -- As far as we know, our computer has never had an undetected error. -- Weisert 葛斯克 愛德華 / 台北市八德路四段
Attachment:
signature.asc
Description: OpenPGP digital signature
-- users mailing list users@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines