How to get the mtime of a file on Linux?

How to get the mtime of a file on Linux from the file’s path?

You can use stat to get the file status including the mtime:

%y
    time of last modification, human-readable 
%Y
    time of last modification, seconds since Epoch

As an example,

$ stat -c %y ./file 
2017-06-26 13:33:06.764042064 +0800
$ stat -c %Y ./file 
1498455186

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *