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.


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.

  • 1
    $ dd bs=4 skip=1 count=1 if=foo.gz 2> /dev/null | perl -nle 'print scalar localtime unpack("i",$_);' # Prints Sat Jul 13 12:21:10 2013 for 1373698270. Tested on win7/cygwin/perl – mosh Mar 24 '18 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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