File modification time (seconds) on Unix

Viewed 55057

On Unix, is there a command to display a file's modification time, precise to the second?

On Linux this is easily done with a "stat -c %y", which returns something like 2009-11-27 11:36:06.000000000 +0100. I found no equivalent on Unix.

12 Answers

Seconds:

date +%s -r /etc/passwd

Or, with more precision (up to nanosecond precision), if your filesystem supports it:

date +%s.%N -r /etc/passwd
Related