Re: checking gzip files



On 12/30/05, Xavier Noria <fxn@xxxxxxxxxxx> wrote:
> Even if gzipped files have always more than 0 bytes, wouldn't it be
> true than all empty gzipped files have the same size, and that non-
> empty gzipped files are greater than that minimum? In this Mac that
> size seems to be 24 bytes.

Nope. Gzipped files have a header which may include filename.

$ touch foo
$ ls -l foo
-rw-r--r-- 1 me mine 0 Dec 30 2005 foo
$ gzip foo
$ ls -l foo.gz
-rw-r--r-- 1 me mine 24 Dec 30 18:04 foo.gz
$ touch foobar
$ ls -l foobar
-rw-r--r-- 1 me mine 0 Dec 30 2005 foobar
$ gzip foobar
$ ls -l foobar.gz
-rw-r--r-- 1 me mine 27 Dec 30 18:04 foobar.gz

Well - it looks like an empty gzipped file with a name takes C<21 +
length($name)> but that's not reliable since the header size may vary.

$ touch foo
$ ls -l foo
-rw-r--r-- 1 me mine 0 Dec 30 2005 foo
$ gzip -n foo # omit name from header
$ ls -l foo.gz
-rw-r--r-- 1 me mine 20 Dec 30 2005 foo.gz

To be true, in gzip file specifications, there is a field with the
size of the uncompressed data - but that's what
zlib/zcat/Compress::Zlib access for us to know the file is empty.
.



Relevant Pages

  • Re: gunzip stdin stream?
    ... I discovered that my currently installed version of gzip -d ... would correctly read plain files, gzipped files, ... for the occasional file that is gzipped without a .gz ... I'm primarily used to writing in perl4 style. ...
    (comp.lang.perl.misc)
  • Re: gunzip stdin stream?
    ... I discovered that my currently installed version of gzip -d ... would correctly read plain files, gzipped files, ... I've been recommending this as the "universal input pipe", ... as the first line of a perl program, and let the $PATH variable figure ...
    (comp.lang.perl.misc)
  • gzip
    ... What is the difference in gzipping on a i386 and a x86_64 machine? ... Both machine use the same version of gzip 1.3.12 but the ... x86_64 gzipped files!!!! ... Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines ...
    (Fedora)
  • Re: negative selection
    ... > I want to run a gzip command on all the files in a directory that have not ... If your gzipped files don't have the '.gz' extension, ...
    (comp.os.linux)