Use stat
to display file status:
stat file.txt
16777221 132843481 -rw-r--r-- 1 jeffkreeftmeijer wheel 0 0 "Mar 2 10:16:36 2023" "Mar 2 10:16:36 2023" "Mar 2 10:16:36 2023" "Mar 2 10:16:36 2023" 4096 0 0 file.txt
To get the time when a file was last modified, pass %a
as the format via the -f
flag:
stat -f "%a" file.txt
1677748596
Times are returned using the decimal output format by default.
To get a string instead, pass %Sa
as the format instead of %a
:
stat -f "%Sa" file.txt
Mar 2 10:16:37 2023
The time can be formatted using by passing a time format with the -t
flag, which takes a strftime
format:
stat -f %Sa -t %Y-%m-%d file.txt
2023-03-02