File modification time (seconds) on Unix File modification time (seconds) on Unix unix unix

File modification time (seconds) on Unix


I found this:

ls --time-style='+%d-%m-%Y %H:%M:%S' -l

Which exports something like this:

root:~# ls --time-style='+%d-%m-%Y %H:%M:%S' -ltotal 0-rw-r--r-- 1 root root 0 16-04-2015 23:14:02 other-file.txt-rw-r--r-- 1 root root 0 16-04-2015 23:13:58 test.txt


According to the man page on my Mac (which has the BSD standard version of stat) you can get the epoch time version of the modification in seconds with:

stat -f %m /etc/passwd

Or if you want to print that out in hours:mins:secs you can do this:

perl -e "print scalar(localtime(`stat -f %m /etc/passwd`))"


The following gives you last modified time in seconds since Epoch:

stat -c%Y <file>