[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gzip -lNv does not output internal timestamp's year
From: |
Scott-Fleming, Ian |
Subject: |
gzip -lNv does not output internal timestamp's year |
Date: |
Mon, 11 Feb 2013 07:33:39 +0000 |
Observed on RedHat 6 & Mac OS X 10.6.8
gzip versions:
RedHat 6: gzip 1.3.12
Mac OS X 10.6.8: gzip 1.4
Problem: gzip -lNv only shows the month, day and time of time stamp, but does
not show the year.
Thus code which is attempting to get original file's timestamp using "gzip
-lNv" cannot determine the full internal timestamp.
Year is obviously stored, because the correct original timestamp is applied
when unzipping with gunzip -N.
(Workaround is shown below)
tst$ ls -l testgz.txt
-rw-r--r--. 1 iscottfl geosciences 111542 Nov 30 2005 testgz.txt
tst$ stat -c %y testgz.txt
2005-11-30 04:15:28.000000000 -0600
address@hidden:/data/gcm_cmip5/tst$ gzip -N testgz.txt
address@hidden:/data/gcm_cmip5/tst$ ls -l testgz.txt.gz
-rw-r--r--. 1 iscottfl geosciences 5789 Nov 30 2005 testgz.txt.gz
tst$ stat -c %y testgz.txt.gz
2005-11-30 04:15:28.000000000 -0600
tst$ gzip -lNv testgz.txt.gz
method crc date time compressed uncompressed ratio
uncompressed_name
defla 66f170b1 Nov 30 04:15 5789 111542 94.8%
testgz.txt
tst$ touch testgz.txt.gz
tst$ ls -l testgz.txt.gz
-rw-r--r--. 1 iscottfl geosciences 5789 Feb 11 01:15 testgz.txt.gz
# workaround:
tst$ file testgz.txt.gz
testgz.txt.gz: gzip compressed data, was "testgz.txt", from Unix, last
modified: Wed Nov 30 04:15:28 2005
# extract internal timestamp for later use
tst$ tstamp=$(date "+%s" -d "$(file -b testgz.txt.gz | awk '{print $10 " " $11
" " $12 " " $13 " " $14}')")
tst$ echo $tstamp
1133345728
As shown in last few lines, workaround is to parse the timestamp from the
"file" utility output instead of gzip, so my world has not fallen to pieces as
a result of gzip not reporting the year. However, I noticed the problem while
developing a script to verify downloaded & zipped files (and spent a grumbling
hour or so finding the workaround.)
I imagine you are aware of this, and consider it a feature rather than a bug,
and have good reason for what is in the code, but felt it worth an email to
point it out, just in case.
Thanks for your attention, and the courtesy of a reply if you have time and
inclination.
address@hidden<mailto:address@hidden>
- gzip -lNv does not output internal timestamp's year,
Scott-Fleming, Ian <=