Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What is a nice command-line trick to tell if a .gz file is really gzipped, as opposed to being a non-Gzip file just named that way?

share|improve this question

2 Answers 2

up vote 8 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.

share|improve this answer
    
Although it works I feel like there should be a better way. –  7hi4g0 May 21 at 15:10

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.

share|improve this answer
    
Interesting info. But it feels like something that were supposed to be on the program with a verify option or something like that. –  7hi4g0 May 21 at 15:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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