开发者

How to know the file is modifed in linux

I want to know what system call is used in linux C programming is used to know whether a file is modified. I know that make utility compiles the file using the modification dates only. I 开发者_开发百科want know how to find whether the file is modified or not.

Thanks in advance


Using md5sum or sha1sum will hash the contents of the file, which should give you a better indication of actual changes than modification dates.


stat(2) gives you file times and more.

Edit 0:

You can look into fcntl(2) and F_NOTIFY flag - you'd have to open the directory, not the file itself though. Or the newer Linux inotify(7) facility.


You can use ls and various flags on it, like -l or -t and pipe to grep or something. That will tell you when the last file was modified. But it doesn't really tell you if the file was modified. I think the only real way you can know that is if you are keeping track of when the last time it was modified in general (like checking from backups or something).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜