According to the manual of bash
file1 -nt file2
True if file1 is newer (according to modification date) than file2, or
if file1 exists and file2 does not
Bash is innacurate when testing modification dates. It ignores fractions
of a second. Is it expected? Coreutils test does it properly.
[kruger@localhost sdl]$ touch a; touch b
[kruger@localhost sdl]$ stat a b
File: 'a'
Size: 0 Blocks: 0 IO Block: 4096 regular empty
file
Device: fd02h/64770d Inode: 1577914 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ kruger) Gid: ( 1000/ kruger)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2013-08-14 22:28:54.100234174 +0200
Modify: 2013-08-14 22:28:54.100234174 +0200
Change: 2013-08-14 22:28:54.100234174 +0200
Birth: -
File: 'b'
Size: 0 Blocks: 0 IO Block: 4096 regular empty
file
Device: fd02h/64770d Inode: 1577915 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ kruger) Gid: ( 1000/ kruger)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2013-08-14 22:28:54.101234176 +0200
Modify: 2013-08-14 22:28:54.101234176 +0200
Change: 2013-08-14 22:28:54.101234176 +0200
Birth: -
[kruger@localhost sdl]$ test b -nt a && echo newer || echo not
not
[kruger@localhost sdl]$ /usr/bin/test b -nt a && echo newer || echo not
newer
[kruger@localhost sdl]$ cat /etc/redhat-release
Fedora release 19 (Schrödinger’s Cat)
[kruger@localhost sdl]$ rpm -q bash coreutils
bash-4.2.45-1.fc19.x86_64
coreutils-8.21-11.fc19.x86_64