What a nice command line trick to tell if a .gz file is really gzipped or just named that way?

link|improve this question

feedback

2 Answers

up vote 5 down vote accepted

You can use the file command to do this. It will look at the magic numbers in the file and tell you what type it really is.

link|improve this answer
feedback

If it is gzip'd the first two bytes are 0x1F and 0x8B.

To get more complicated than that you will need to understand the file format. See here: http://www.gzip.org/zlib/rfc-gzip.html and go down to "Member header and trailer" section where you can identify a gzip by its 10 byte header.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.