通过校验和查找目录中修改的文件

Finding modified files in a directory through checksum

我创建了两个文件,一个是文件夹中所有单独文件的校验和,另一个是同一文件夹中所有文件经过一些修改(增删改查)后的单独校验和。我需要找出在校验和命令的第二个 运行 期间被修改的文件。

我试过使用 comm 命令。

comm -23 firstfile secondfile | awk '{print }' |sort > added.txt
comm -23 secondfile firstfile | awk '{print }' |sort > deleted.txt

我正在尝试找到一种方法来找到已修改的文件。

md5sum *.txt > sum1

md5sum *.txt > sum2

diff sum1 sum2

校验和不是监视更改的好方法,因为它们仅限于校验和差异。

如果你想对文件系统事件采取行动,你可以使用 inotify (http://man7.org/linux/man-pages/man7/inotify.7.html)

如果你只是想看赛事,你可以使用iwatch (http://iwatch.sourceforge.net/documentation.html) in order to detect changes in a directory. An alternative to this is watchman which is developed by fakebook (https://www.tecmint.com/watchman-monitor-file-changes-in-linux/)