How to get the timestamp of a file?
How to get the timestamp of a file on Linux?
I know two commands: "ls -l" and "stat". Is there any other command that can get that information? Thanks for your attention and look forward to your reply. |
stat is the best tool to access all 3 (atime, ctime, mtime) quickly. The man page doesn't list any other tools either... There's a useful definition of these at http://www.brandonhutchinson.com/ctime_atime_mtime.html.
|
A quick google came up with the command: file -p test.txt
It may give timestamp on some distros but not on my FC box. |
Actually could you be more specific in you query why do you need some more commands when these are solving a problem.
If you are probably creating some program,I think fstat() is the system call you are looking at |
Yep, it's the same on Slackware - using '-p' will attempt to preserve the access time, but none of the 'file' program's options display the atime, ctime or mtime.
|
Also, the find cmd has atime/mtime/ctime options. We'd be able to help a lot more if you could give us some details as to what exactly you are trying to do.
|
Thanks all you guys.
What I want is to retain only the timestamp while filter out all the others. So, a clear method to present the timestamp of a file is necessary to deal with the output of the above commands. But these outputs is too complex for me to cope with. That's it. Thanks for your attention and look forward to your reply. |
I hope this is what you're looking for...
If you use stat to display the info about a file and it produces the following: Code:
$ stat 405938.png Code:
$ stat 405938.png | grep 'Access: [[:digit:]]' | cut -d' ' -f2,3,4 Code:
$ stat 405938.png | grep 'Modify: ' | cut -d' ' -f2,3,4 Code:
$ stat 405938.png | grep 'Change: ' | cut -d' ' -f2,3,4 |
All times are GMT -5. The time now is 01:48 AM. |