[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#7365: stat bug: %Z appends .000000000

From: Eric Blake
Subject: bug#7365: stat bug: %Z appends .000000000
Date: Wed, 10 Nov 2010 11:02:30 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20101103 Fedora/1.0-0.33.b2pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.6

On 11/10/2010 07:59 AM, IgnorantGuru wrote:
> $ stat -c %Z examplefile 
> 1289397609.000000000
> stat (GNU coreutils) 8.6 installed from Arch Linux repos, executing in a bash 
> shell.
> This behavior changed recently - didn't used to have the .000000000 which 
> breaks scripts that use stat.  eg
> line 297: ((: 1289301692.000000000: syntax error: invalid arithmetic operator 
> (error token is ".000000000")

Technically, this is not a bug, since it was documented in NEWS:

  stat now outputs the full sub-second resolution for the atime,
  mtime, and ctime values since the Epoch, when using the %X, %Y, and
  %Z directives of the --format option.  This matches the fact that
  %x, %y, and %z were already doing so for the human-readable variant.

However, it has already been discussed (extensively!) on this list that
it was somewhat an undesirable change, so for the soon-to-be-released
8.7, the behavior is changing yet again:


  stat's %X, %Y, and %Z directives once again print only the integer
  part of seconds since the epoch.  This reverts a change from
  coreutils-8.6, that was deemed unnecessarily disruptive.  To obtain
  a full resolution time stamp for %X, use %.X; if you want (say) just
  3 fractional digits, use %.3X.  Likewise for %Y and %Z.

  stat's new %W format directive would print floating point seconds.
  However, with the above change to %X, %Y and %Z, we've made %W work
  the same way as the others.

so that %Z will once again omit nanoseconds, %.Z will print 9
nanoseconds, %#.Z will print as many non-zero fractional seconds as
supported by the fs, and %#.3Z will truncate to milliseconds.

Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]