Extract timestamp from a gzip file

gziptimestamps

How can I know the raw original timestamp of a file foo compressed with gzip without having to decompress foo.gz?

gzip --verbose --list foo.gz and file foo.gz will print formatted date and time.

Best Answer

Extract the timestamp manually. Assuming that the compressed file has a single member (this is normally the case with gzip):

<foo.gz dd bs=4 skip=1 count=1 | od -t d4

This prints the raw timestamp, i.e. the number of seconds since 1970-01-01 00:00 UTC, in decimal.

Related Question