Given a gzip compressed file, how do I know what compression level (1-9) was used for it?
It is stored in the header of file. To see it, use
file command. For example:
$ file testfile.gz testfile.gz: gzip compressed data, from Unix, last modified: Sun Sep 15 14:22:19 2013, max compression
Unfortunately there are only three possible values in the header: max speed (level 1), max compression (level 9) and "normal" (all other levels). But better than nothing!
There is no direct way of knowing it. It most probably 6 (the current default) or 9 (the best compression). you need to try and compare.