REQ: Way to predict size of tar/gzip archive

REQ: Way to predict size of tar/gzip archive

Post by z_crof.. » Fri, 15 Nov 1996 04:00:00



I need to compress a directory for archiving purposes,
but before I can do that I need to know how much space
it will occupy.  Is there a way I can find out how
much space it will take to tar | gzip it without
having to actually create the compressed file?  I
thought perhaps about

        tar -cvf - . | gzip - > /dev/null

but I don't know if that would work.  Any comments via
email would be appreciated.


 
 
 

REQ: Way to predict size of tar/gzip archive

Post by Nikita V. Youshchenk » Fri, 15 Nov 1996 04:00:00



> I need to compress a directory for archiving purposes,
> but before I can do that I need to know how much space
> it will occupy.  Is there a way I can find out how
> much space it will take to tar | gzip it without
> having to actually create the compressed file?  I
> thought perhaps about

>         tar -cvf - . | gzip - > /dev/null

> but I don't know if that would work.  Any comments via
> email would be appreciated.



There is one very silly way:

/* count.c */
#include <stdio.h>
main()
{
  int c,i;
  i = 0;
  while ( (c=getchar())!=EOF )  i++;
  printf ( "%d/n", i );

Quote:}

And use "tar cf ... | gzip - | count"

P.s. there is a standart unix utility that counts it's stdio size,
but I can't remember it's name ...

 
 
 

REQ: Way to predict size of tar/gzip archive

Post by G Sumner Haye » Fri, 15 Nov 1996 04:00:00




> > I need to compress a directory for archiving purposes,
> > but before I can do that I need to know how much space
> > it will occupy.  Is there a way I can find out how
> > much space it will take to tar | gzip it without
> > having to actually create the compressed file?  I
> > thought perhaps about

> There is one very silly way:

> /* count.c */
> #include <stdio.h>
> main()
> {
>   int c,i;
>   i = 0;
>   while ( (c=getchar())!=EOF )  i++;
>   printf ( "%d/n", i );
> }

> And use "tar cf ... | gzip - | count"

> P.s. there is a standart unix utility that counts it's stdio size,
> but I can't remember it's name ...

wc(1).

tar cf ... | gzip - | wc -c

(-c tells it to output # of bytes).

Your program won't work on files larger than MAXINT bytes; using longs
would be better, but wc is probably the best solution.

Cordially,

  Sumner

Please don't CC: postings to me, my mailbox is already full enough.

 
 
 

REQ: Way to predict size of tar/gzip archive

Post by Mats Andtbac » Sun, 17 Nov 1996 04:00:00



Quote:>I need to compress a directory for archiving purposes,
>but before I can do that I need to know how much space
>it will occupy.  Is there a way I can find out how
>much space it will take to tar | gzip it without
>having to actually create the compressed file?

tar cvf - . | gzip -9 | wc -c

the -9 parameter to gzip *does* make a difference, in my experience.
tar, by default, seems not to use it; i've lately taken to manually
gzipping .tar files.
--
        "...Everybody got this broken feeling
         like their father or their dog just died..."
                                                        - Leonard Cohen

 
 
 

REQ: Way to predict size of tar/gzip archive

Post by G Sumner Haye » Sun, 17 Nov 1996 04:00:00



> tar cvf - . | gzip -9 | wc -c

> the -9 parameter to gzip *does* make a difference, in my experience.
> tar, by default, seems not to use it; i've lately taken to manually
> gzipping .tar files.

The -9 makes an almost insignificant difference on most files.  If you
really need extra compression, use a better compression program (like
bzip, available at sunsite).  

xemacs.tar.gz   16MB (gzip -9)
xemacs.tar.bz   12MB (bzip)

That's a significant savings.

Cordially,

  Sumner

--
Respond by post or email, but please don't CC: postings to me; my mailbox
is already quite full.

 
 
 

REQ: Way to predict size of tar/gzip archive

Post by Eric Berengui » Mon, 18 Nov 1996 04:00:00




...
: xemacs.tar.gz   16MB (gzip -9)
: xemacs.tar.bz   12MB (bzip)

try bzip -9 ;)

--

   Supelec - Residence des eleves - 91192 Gif sur Yvette - 01 69 85 50 16
                   http://hal.rez-gif.supelec.fr/~eric

 
 
 

REQ: Way to predict size of tar/gzip archive

Post by Mats Andtbac » Tue, 19 Nov 1996 04:00:00



[...]

Quote:>The -9 makes an almost insignificant difference on most files.  If you
>really need extra compression, use a better compression program (like
>bzip, available at sunsite).  

i've found this now, after some searching - the distribution on
Sunsite is badly broken and good only for getting the primary site
from the LSM - and i'm rapidly getting to like it. it seems lightning
fast, but then i've so far only run it on an UltraSPARC, which might
bias things just a tiny bit. :-)

now if only i could hack GNU tar into recognizing it...
--
        "...Everybody got this broken feeling
         like their father or their dog just died..."
                                                        - Leonard Cohen

 
 
 

1. Which is better: tar->gzip or gzip->tar?

For best compression on previously uncompressed files,
which is better: tar * | gzip, or gzip * | tar?
IE, is it best to tar compressed files, or compress
a tar file of uncompressed files?  Does gzip -r * work
better than either solution?

I'm looking for the most robust method to archive groups
of files.

---


Mayo Medical and Graduate Schools        
200 1st St. SW, Rochester, MN 55905

2. LINUX BBS list

3. Kernel 2.2.0pre6 crashes permanently

4. Q: Does gzip or tar verifyes CRC on archives?

5. Introduction to Unix Course On-line, Revised

6. tar archive size (was Shell to add column of numbers)

7. How can i send a big email?

8. tar archive of fixed size

9. ufsdump archive --> tar archive ?

10. req. known ways to crash a system

11. Extracting files with tar and uncompress fails with tar: Archive - EOF not on block boundary