10

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.

1 Answer 1

8

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
  • 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
    Commented Mar 24, 2018 at 15:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .