Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Has the GNU coreutils (8.6) version of stat changed? After a recent update, some scripts I wrote that call stat are not working as expected; in particular, I had been making use of stat -c %Y "${filename}". This is supposed to return the time of last modification in the form of seconds since "Epoch". However, I could have sworn this used to take the form of a whole integer. However, I'm now getting output from this of the form 1287630625.956667227 rather than 1287630625. Since Bash can't handle floating point arithmetic, this is a litttle annoying. Is this a deliberate change? Or a bug? Or has my memory gone fuzzy? I tried searching for information on this, but couldn't find anything.

share|improve this question
    
+1 well presented question –  msw Oct 21 '10 at 15:08
1  
I wanted to come back and note that they've reverted to the old behavior for version 8.7 of coreutils, though if you want the decimal places, you can use, e.g., stat -c $.5Y filename to get 5 decimal places. Otherwise you get none. –  frabjous Nov 21 '10 at 20:55
add comment

2 Answers

up vote 9 down vote accepted

stat: print timestamps to full resolution was committed to coreutils-8.6.

$ git clone git://git.savannah.gnu.org/coreutils.git
$ cd coreutils
$ git log -1 --grep=time -- src/stat.c
commit 9069af45e691d1252c727da66aa4f3f3c7f1ea29
Author: Eric Blake 
Date:   Thu Sep 30 16:42:13 2010 -0600

    stat: print timestamps to full resolution

    * src/stat.c (epoch_time): New function.
    (print_stat): Use it for %[WXYZ].
    * NEWS: Document this.
    * tests/touch/60-seconds: Adjust test to match.
    * tests/misc/stat-birthtime: Likewise.
$ git describe --contains 9069af4
v8.6~29
share|improve this answer
    
Thanks. One would have thought that for backwards compatibility they would have introduced an alternative notation and not replaced %[WXYZ]. –  frabjous Oct 21 '10 at 16:29
add comment

This was unnecessarily disruptive and was reverted for >= coreutils-8.7 Since then you need to specify %.Y etc to get the fractional part included

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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