Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File modification time (seconds) on Unix

Tags:

file

unix

time

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.

like image 524
ExpertNoob1 Avatar asked Nov 27 '09 10:11

ExpertNoob1


People also ask

What is modification time in Unix?

The modified time is when a file last had its contents modified. And the change time is when a file last had its metadata changed (such as file permissions or the name of the file).

How do you check file modification time in Linux?

The syntax is pretty simple; just run the stat command followed by the file's name whose last modification date you want to know, as shown in the example below. As you can see, the output shows more information than previous commands. It is important to differentiate the modification and change dates.


1 Answers

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' -l total 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 
like image 146
Aftershock Avatar answered Oct 02 '22 15:10

Aftershock